Home > Article > Backend Development > How to Fix "undefined reference to boost::system::system_category()" Linking Error on Ubuntu?
Linking Error: undefined reference to boost::system::system_category()
When attempting to compile a program utilizing Boost libraries on Ubuntu 11.10, an error message "undefined reference to boost::system::system_category()" may arise. This indicates an issue in linking the program to the Boost library.
Solution:
The error occurs because the program depends on the Boost library's system component, boost_system. To resolve the issue, add the linker option -lboost_system to the compiler command line. This instructs the compiler to link against the boost_system library.
For example, if your original compiler command is:
gcc -o my_program my_program.cpp
Modify it to include the linker option:
gcc -o my_program my_program.cpp -lboost_system
By adding this option, the compiler will locate and link the necessary boost_system library, which resolves the undefined reference error.
The above is the detailed content of How to Fix "undefined reference to boost::system::system_category()" Linking Error on Ubuntu?. For more information, please follow other related articles on the PHP Chinese website!