Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) undefined reference to 'boost::thread::thread()'

 

Link error.

 

 

 

 

 

Full error message

 

/MyFolder/main.o:: In function 'main':
/MyFolder/main.cpp:5: error: undefined reference to 'boost::thread::thread()'
/MyFolder/main.cpp:5: error: undefined reference to 'boost::thread::~thread()'
:: 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/thread.hpp>

int main()
{
  boost::thread t;
}

 

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 boost::thread library. Add the following line to your project file:

 

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

 

 

 

 

 

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

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict