I just installed Boost usig sudo apt-get
. After that, I wrote the following code for testing one of my the functions I had declared in "first_n_follow.h"
#include<iostream>
#include<string.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include "first_n_follow.h"
#define BOOST_TEST_MODULE MyTest
#include <boost/test/unit_test.hpp>
using namespace std;
BOOST_AUTO_TEST_CASE( my_test )
{
set<char> sample = {'b','c','d'};
map<char, set<char>> sample_map;
sample_map['a'] = sample;
BOOST_TEST(print_map(sample_map)==0);
}
Sadly, when I compile the above file first_n_follow_test.cpp
using the following command:
g++ -o test.o first_n_follow_test.cpp
I get the following error:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
/usr/bin/ld: /tmp/ccefJDJt.o: in function `my_test_invoker()':
first_n_follow_test.cpp:(.text+0x100): undefined reference to `boost::unit_test::unit_test_log_t::set_checkpoint(boost::unit_test::basic_cstring<char const>, unsigned long, boost::unit_test::basic_cstring<char const>)'
followed by a long stack trace. Any ideas, as to what the problem might be?
Even if I replace the call to my code and write
BOOST_TEST(0==0);
,
it shows the same error.
Any help is very appreciated.
Linkage of boost unit test framework library is missing
g++ -o test.o first_n_follow_test.cpp -lboost_unit_test_framework
Undefined reference errors usually means missing libraries or object files during linkage stage