Undefined reference to boost::system::generic_category despite linking with boost_system

1.3k Views Asked by At

My compilation command is:

g++ -I/home/foo/boost_1_56_0 -L/home/foo/boost_1_56_0/stage/lib -lboost_system -lboost_filesystem -lpthread -lboost_thread -lboost_system -lboost_filesystem -lpthread -lboost_thread main.cpp foo.cpp

I get an undefined reference to boost::system::generic_category error despite the fact that I link it with -lboost_thread.

I also get undefined references to:

boost::system::generic_category and pthread_detach.

1

There are 1 best solutions below

0
On BEST ANSWER

You should specify the libraries after the source file(s).

Also, prefer -pthread over manually linking libpthread.so

g++ -I/home/foo/boost_1_56_0 -L/home/foo/boost_1_56_0/stage/lib -pthread main.cpp foo.cpp -lboost_system -lboost_filesystem -lboost_thread