2016-09-15 74 views
1

我寫的代碼如何將boost庫鏈接到我的項目?

#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; 
} 

和Qt Creator中

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

我已經得到了這些錯誤

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 function boost::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 function boost::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 function boost::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 to boost::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

我怎樣才能解決這些問題增加了串親文件?以及如何讓應用程序工作?

+5

boost_system是系統特定功能的增強庫。你想'boost_thread' – Hayt

回答

2
LIBS += -L/usr/lib/x86_64-linux-gnu -lboost_system -lboost_thread 
相關問題