6

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?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Sahil Sachdeva
  • 442
  • 3
  • 5
  • 12
  • What about `-lboost_system`? – Kerrek SB Jul 03 '13 at 19:05
  • It is also linked, since i am also using asio. – Sahil Sachdeva Jul 03 '13 at 19:27
  • Can you show your actual linker invocation? – Kerrek SB Jul 03 '13 at 19:33
  • Here it is: Invoking: GCC C++ Linker g++ -L/usr/local/boost_1_54_0/bin.v2/libs -o "test" ./src/main.o -lboost_system -lboost_thread-mt ./src/main.o: In function `boost::thread::start_thread()': /usr/local/boost_1_54_0/boost/thread/detail/thread.hpp:180: undefined reference to `boost::thread::start_thread_noexcept()' ./src/main.o: In function `boost::thread::join()': /usr/local/boost_1_54_0/boost/thread/detail/thread.hpp:756: undefined reference to `boost::thread::join_noexcept()' collect2: ld returned 1 exit status make: *** [test] Error 1 – Sahil Sachdeva Jul 03 '13 at 19:34
  • Hm... you don't actually have `boost_thread` in there, only `boost_thread-mt`. Could that matter? – Kerrek SB Jul 03 '13 at 19:37
  • This is was just an experiment from one of the answers here.Same error with -lboost-thread: g++ -L/usr/local/boost_1_54_0/bin.v2/libs -o "test" ./src/main.o -lboost_system -lboost_thread ./src/main.o: In function `boost::thread::start_thread()': /usr/local/boost_1_54_0/boost/thread/detail/thread.hpp:180: undefined reference to `boost::thread::start_thread_noexcept()' ./src/main.o: In function `boost::thread::join()': /usr/local/boost_1_54_0/boost/thread/detail/thread.hpp:756: undefined reference to `boost::thread::join_noexcept()' collect2: ld returned 1 exit status make: *** [test] Error 1 – Sahil Sachdeva Jul 03 '13 at 19:40

1 Answers1

5

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"
NREZ
  • 942
  • 9
  • 13
Ana
  • 85
  • 1
  • 8
  • See [this answer](https://stackoverflow.com/questions/41393211) for the solution when using CMake. – ulatekh Mar 15 '22 at 15:21