gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 03:38:33 30 4
gpt4 key购买 nike

我已经写好了代码

#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: 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

我该如何修复它们?以及如何使应用程序运行?

最佳答案

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

关于c++ - 如何将 boost 库链接到我的项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39509830/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com