程序如下#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
添加回答
举报
0/150
提交
取消