Search code examples
c++boostbuildlinkereclipse-cdt

Failed to link libboost_system and libboost_thread


I am trying to make a project which includes Boost library and Gstreamer framework in different boost threads.

I am using eclipse CDT (C++ lang) IDE to program. and I am facing this error "undefined reference to boost::system::generic_category()". I have looked at few of the similar posts which unanimously suggest to add -lboost_system and -lboost_thread in the g++ linking. However I am still facing the issue.

Here are few lines from the eclipse console that I am looking at:

Building target: IBMCmake

Invoking: GCC C++ Linker

g++ -L/usr/lib64 -L/usr/local/lib64 -L/usr/lib -o "IBMCmake"  ./src/WatsonAuth/IbmTokenGenerator.o  ./src/GstRtpDepay/GstRtpDepayloader.o  ./src/IbmWebSock.o ./src/main.o   -lboost_system -lboost_thread -lpthread -lglib-2.0 -lgstreamer-1.0 -lgobject-2.0 -lcurl -lssl -lcrypto
./src/GstRtpDepay/GstRtpDepayloader.o: In function `boost::system::error_category::std_category::equivalent(int, std::error_condition const&) const':
/usr/include/boost/system/error_code.hpp:676: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:679: undefined reference to `boost::system::generic_category()'
...
...
...
./src/IbmWebSock.o: In function `boost::system::error_code::error_code()':
/usr/include/boost/system/error_code.hpp:449: undefined reference to `boost::system::system_category()'
...
...
...

I Am not sure what might be causing this. How do I get this error solved? Any Suggestions?

Please Note: "IBMCmake" is just a name given to the project by me. Not using cmake to compile.


Solution

  • boost_system and boost_threads are usually system-integrated. Thus it is possible to have corrupted links or updated links.

    I re-installed the boost from the instruction on Boost older versions

    This solved the linking problem.