Home  >  Article  >  Backend Development  >  How to Fix 'undefined reference to boost::system::system_category()' Linking Error on Ubuntu?

How to Fix 'undefined reference to boost::system::system_category()' Linking Error on Ubuntu?

Patricia Arquette
Patricia ArquetteOriginal
2024-11-11 02:00:02487browse

How to Fix

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!

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