I'm trying to build some code. Here is the error I'm getting:
main.o: In function `__static_initialization_and_destruction_0':
/home/jmbeck/Downloads/boost_1_48_0/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
There is more, but I don't think it's relevant.
Here is the build command:
g++ -I/home/jmbeck/Downloads/boost_1_48_0
-L/home/jmbeck/Downloads/boost_1_48_0/stage/lib
-lm
-lboost_system
-lboost_thread
-lboost_regex
main.cpp
The /home/jmbeck/Downloads/boost_1_48_0/stage/lib directory contains the expected files:
libboost_system.a
libboost_system.so@
libboost_system.so.1.48.0*
libboost_thread.a
libboost_thread.so@
libboost_thread.so.1.48.0*
libboost_regex.a
libboost_regex.so@
libboost_regex.so.1.48.0*
... etc...
I've tried building a quick program that didn't use the pre-compiled libraries, and it compiled just fine. It finds the appropriate headers, but not the libraries.
What am I doing wrong?
Often linkers require that libraries be ordered as most dependent to least dependent (I believe MS does not). In this case probably thread or regex depends on system, so you'd need to list the
-lsystem
after the other boost library that depends on it.Try putting the libraries after
main.cpp
.I've experienced some weirdness in the past when GCC ignores libraries because it doesn't think they're used, before reaching my source files.