Boost/thread.hpp MacOS X C++ Linker

Discussion in 'Mac Programming' started by ronieh, Jul 3, 2014.

  1. ronieh macrumors newbie

    Jul 3, 2014

    I have installed boost on my OS X 10.9.4, and can successfully build executables using some boost libraries, for example <boost/date_time/gregorian/gregorian.hpp>

    However, when I try and build including boost/thread.hpp, I get the following link error. My BoostLearner.cpp does nothing more than #include <boost/thread.hpp>

    I have checked various forums, but could not see an answer which has solved the issue.

    If anybody can help it would be much appreciated. I have it working on my old laptop, but would be good to be able to build on my new one also.

    Invoking: MacOS X C++ Linker
    g++ -L/opt/local/lib/ -o "BoostLearner" ./src/BoostLearner.o -lboost_thread-mt
    Undefined symbols for architecture x86_64:
    "boost::system::system_category()", referenced from:
    ___cxx_global_var_init2 in BoostLearner.o
    "boost::system::generic_category()", referenced from:
    ___cxx_global_var_init in BoostLearner.o
    ___cxx_global_var_init1 in BoostLearner.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [BoostLearner] Error 1

    Thank you....
  2. Cromulent macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
    You need to link against Boost System as well. The documentation is quite clear on this. You might also need to link against Boost Chrono if you use some of the time interfaces in Boost Thread.
  3. ronieh thread starter macrumors newbie

    Jul 3, 2014
    builds now

    Thanks a lot for the reply. I was making a bit of a mountain out it....

    Invoking: MacOS X C++ Linker
    g++ -L/opt/local/lib/ -o "BoostLearner" ./src/BoostLearner.o -lboost_thread-mt -lboost_system-mt
    Finished building target: BoostLearner

Share This Page