Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined reference to Boost Thread

I am trying to compile and use the Boost 1.54 libraries and have run into a deadend.

I compiled and installed the libraries like mentioned in the documentation:

./bootstrap.sh
./b2 install

I even tried a complete reinstall using:

./bootstrap.sh
./b2 threading=multi install

I have linked using -lboost_thread and -L*path to boost*/bin.v2/libs

I am still getting the following linker errors:

undefined reference to boost::thread::start_thread_noexcept()
undefined reference to boost::thread::join_noexcept()

I am using gcc 4.6.3 on Ubuntu 12.04 in Eclipse.

Does anyone know how I can fix this?

like image 381
Sahil Sachdeva Avatar asked Oct 04 '22 15:10

Sahil Sachdeva


1 Answers

After quite a bit of pain with the default boost on ubuntu repositories, I installed boost 1.54.0 (from the official webpage) with the default options, and the following worked for me:

g++ test.cpp -o test -L/usr/local/lib/ -lboost_thread

P.S: On Ubuntu 12.04, gcc 4.63.

P.S2: Included in my test.cpp are:

#include "boost/thread/thread.hpp"
#include  "boost/bind.hpp"
like image 70
Ana Avatar answered Oct 06 '22 04:10

Ana