Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) undefined reference to 'boost::system::get_system_category()'

 

Link error.

 

 

 

 

 

Full error message

 

/MyFolder/main.o:: In function '__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:205: error: undefined reference to 'boost::system::get_system_category()'
/usr/include/boost/system/error_code.hpp:206: error: undefined reference to 'boost::system::get_generic_category()'
/usr/include/boost/system/error_code.hpp:211: error: undefined reference to 'boost::system::get_generic_category()'
/usr/include/boost/system/error_code.hpp:212: error: undefined reference to 'boost::system::get_generic_category()'
/usr/include/boost/system/error_code.hpp:213: error: undefined reference to 'boost::system::get_system_category()'
/MyFolder/main.o:: In function 'boost::asio::error::get_system_category()':
/usr/include/boost/asio/error.hpp:218: error: undefined reference to 'boost::system::get_system_category()'
:: error: collect2: ld returned 1 exit status

 

 

 

 

 

 

Cause

 

IDE: Qt Creator 1.2.0

Project type: Qt4 Console Application

Compiler: G++ 4.4.1

Libraries used:

 

The following source code was used:

 

#include <boost/asio.hpp>

int main()
{
  boost::asio::io_service io_service;
}

 

The following project file was used:

 

#-------------------------------------------------
#
# Project created by QtCreator 2010-07-21T19:37:18
#
#-------------------------------------------------
QT += core
QT -= gui
TARGET = MyTarget
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp

 

 

 

 

 

Solution

 

You need to link against the Asio library. Add the following line to your project file:

 

LIBS += -L/usr/local/lib -lboost_system

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict