首页 文章

如何将boost库链接到我的项目?

提问于
浏览
1

我写了代码

#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中的pro文件中添加了字符串

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

我收到了这些错误

build-test_not_qt_1-Desktop-Debug / main.o:-1:在函数boost :: detail :: thread_data_base :: thread_data_base()':/ build-test_not_qt_1-Desktop-Debug / main.o: - 1:在functionboost中:: detail :: thread_data_base :: thread_data_base()':build-test_not_qt_1-Desktop-Debug / main.o:-1:在函数boost :: thread :: start_thread()':build-test_not_qt_1-Desktop-Debug / main .o:-1:在functionboost :: thread :: start_thread()':build-test_not_qt_1-Desktop-Debug / main.o:-1:在函数boost :: thread ::〜thread()':build-test_not_qt_1 -Desktop-Debug / main.o:-1:在functionboost :: thread :: ~thread()':build-test_not_qt_1-Desktop-Debug / main.o:-1:在函数boost :: detail :: thread_data < void(*)()> ::〜thread_data()':/ usr / include / boost / thread / debug / thread.hpp:91:错误:未定义引用toboost :: detail :: thread_data_base :: ~thread_data_base()' (.rodata._ZTIN5boost6detail11thread_dataIPFvvEEE [_ZTIN5boost6detail11thread_dataIPFvvEEE] 0x10): - 1:错误:对于:: typeinfo for boost :: detail :: thread_data_base'的未定义引用:-1:错误:collect2:错误:ld返回1退出状态

我怎么修理它们?以及如何使应用程序正常工作?

1 回答

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

相关问题