2

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.

Niall
  • 28,969
  • 9
  • 96
  • 135
batman
  • 4,684
  • 11
  • 50
  • 80

1 Answers1

3

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

sehe
  • 350,152
  • 45
  • 431
  • 590