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
  • 30,036
  • 10
  • 99
  • 142
batman
  • 5,022
  • 11
  • 52
  • 82

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
  • 374,641
  • 47
  • 450
  • 633