Undefined reference to Boost Thread

14,339

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"
Share:
14,339

Related videos on Youtube

Sahil Sachdeva
Author by

Sahil Sachdeva

Updated on September 15, 2022

Comments

  • Sahil Sachdeva
    Sahil Sachdeva over 1 year

    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?

  • ulatekh
    ulatekh about 2 years
    See this answer for the solution when using CMake.