Home > Backend Development > C++ > 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
Release: 2024-11-11 02:00:02
Original
526 people have browsed it

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
Copy after login

Modify it to include the linker option:

gcc -o my_program my_program.cpp -lboost_system
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template