knowill
knowill

Reputation: 69

how can i link the boost library to my project?

i've written the code

#include <iostream>
#include <boost/thread/thread.hpp>

using namespace std;

void f1()
{
    cout <<"Hello world, I'm a thread1!"<<endl;
}

int main()
{
    boost::thread t1(&f1);
return 0;
}

and added the string in pro file in qt creator

LIBS += -L/usr/lib/x86_64-linux-gnu -lboost_system

i've gotten these errors

build-test_not_qt_1-Desktop-Debug/main.o:-1: In function boost::detail::thread_data_base::thread_data_base()': /build-test_not_qt_1-Desktop-Debug/main.o:-1: In functionboost::detail::thread_data_base::thread_data_base()': build-test_not_qt_1-Desktop-Debug/main.o:-1: In function boost::thread::start_thread()': build-test_not_qt_1-Desktop-Debug/main.o:-1: In functionboost::thread::start_thread()': build-test_not_qt_1-Desktop-Debug/main.o:-1: In function boost::thread::~thread()': build-test_not_qt_1-Desktop-Debug/main.o:-1: In functionboost::thread::~thread()': build-test_not_qt_1-Desktop-Debug/main.o:-1: In function boost::detail::thread_data<void (*)()>::~thread_data()': /usr/include/boost/thread/detail/thread.hpp:91: error: undefined reference toboost::detail::thread_data_base::~thread_data_base()' (.rodata._ZTIN5boost6detail11thread_dataIPFvvEEE[_ZTIN5boost6detail11thread_dataIPFvvEEE]+0x10):-1: error: undefined reference to `typeinfo for boost::detail::thread_data_base' :-1: error: collect2: error: ld returned 1 exit status

how can I fix them? and how can I make the application working?

Upvotes: 1

Views: 605

Answers (1)

vz0
vz0

Reputation: 32923

LIBS += -L/usr/lib/x86_64-linux-gnu -lboost_system -lboost_thread

Upvotes: 2

Related Questions