Home  >  Article  >  Backend Development  >  How do I fix "undefined reference to boost::system::system_category()" errors when compiling Boost programs?

How do I fix "undefined reference to boost::system::system_category()" errors when compiling Boost programs?

Susan Sarandon
Susan SarandonOriginal
2024-11-15 07:11:02821browse

How do I fix

Troubleshooting Compilation Issues with Boost

When compiling programs that rely on Boost libraries, you may encounter errors like "undefined reference to boost::system::system_category()." This issue stems from using a Boost library that requires the boost_system library.

Unlike all Boost libraries, boost_system is not part of the core Boost package. To resolve the compilation error, you must explicitly link your program against boost_system. When using gcc, append the following flag to your compiler command line:

-lboost_system

This flag ensures that the compiler links against the boost_system library, providing the necessary symbols and resolving the undefined reference error. By explicitly linking against boost_system, you can successfully compile your program and eliminate the error.

The above is the detailed content of How do I fix "undefined reference to boost::system::system_category()" errors when compiling Boost programs?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn