程序如下#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
提交
取消