Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) undefined reference to 'boost::filesystem::detail::get_current_path_api'

 

link error.

 

 

 

 

 

Full error message

 

/home/richel/qtsdk-2010.04/bin/Projects/Website/CppFile-build-desktop/main.o:: In function `boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> boost::filesystem::current_path<boost::filesystem::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem::path_traits> >()':
/usr/include/boost/filesystem/operations.hpp:530: error: undefined reference to `boost::filesystem::detail::get_current_path_api(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
:: error: collect2: ld returned 1 exit status

 

 

 

 

 

Cause

 

Operating system: Ubuntu 10.04 LTS Lucid Lynx

IDE: Qt Creator 2.0.0

Project type: Console Application

Compiler: G++ 4.4.1

Libraries used:

 

 

 

 

 

Qt project file

 

#-------------------------------------------------
#
# Project created by QtCreator 2010-08-02T13:45:48
#
#-------------------------------------------------
QT += core
QT -= gui
TARGET = MyTarget
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
LIBS += -L/usr/local/lib -lboost_system
SOURCES += main.cpp

 

 

 

 

 

Source code

 

 

#include <boost/filesystem.hpp>

int main()
{
  boost::filesystem::path my_path(
    boost::filesystem::initial_path<boost::filesystem::path>());
}

 

 

 

 

 

Solution

 

Add the following line to the Qt project file:

 

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

 

 

 

 

 

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

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict