我写的代码如何将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 functionboost::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 functionboost::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 functionboost::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
我怎样才能解决这些问题增加了串亲文件?以及如何让应用程序工作?
boost_system是系统特定功能的增强库。你想'boost_thread' – Hayt