编译命令g++ aa.cpp -lboost_thread 出的错误,请问该怎么改?

程序如下#define BOOST_THREAD_USE_LIB
#include <iostream>
#include <string>
#include <boost/thread.hpp>
using namespace std;
void threadRoutine(void)
{
boost::xtime time;
time.nsec = 0;
time.sec = 20;
cout<<"线程函数做一些事情" << endl;
boost::thread::sleep(time);  
}
int main(void)
{
string str;
cout<<"输入任意字符开始创建一个线程..." << endl;
cin>>str;
boost::thread t(&threadRoutine);
t.join();
cout<<"输入任意字符结束运行..."<<endl;
cin >> str;
return 0;
}
编译命令g++ aa.cpp -lboost_thread
出的错误
/tmp/ccRWsAsP.o: In function `main':
aa.cpp:(.text+0x11c): undefined reference to `boost::thread::~thread()'
aa.cpp:(.text+0x13d): undefined reference to `boost::thread::~thread()'
collect2: ld 返回 1

繁花如伊
浏览 83回答 1
1回答

翻过高山走不出你

楼主啊,很明显你缺少对thread库的引用.连接器找不到符号.
打开App,查看更多内容
随时随地看视频慕课网APP