首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

编译boost程序疏失

2013-08-04 
编译boost程序出错#define BOOST_THREAD_USE_LIB#include iostream#include string#include boost/th

编译boost程序出错

#define BOOST_THREAD_USE_LIB
#include <iostream>
#include <string>
#include <boost/thread.hpp>
using namespace std;
using namespace boost;
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 -lpthread -lboost_filesystem

错误:
/tmp/ccFzAbMa.o: In function `main':
aa.cpp:(.text+0x11c): undefined reference to `boost::thread::~thread()'
aa.cpp:(.text+0x13d): undefined reference to `boost::thread::~thread()'
请问大家怎么解决,网上看了很多说法,都解决不了

[解决办法]
vs2008上测试没问题。
[解决办法]
应该是有些boost的库文件没有链接。
[解决办法]
你用了xtime,难道是time库没有编译????
[解决办法]
你有库没链接吧?
[解决办法]
boost thread库要单独编译出静态库或动态库再链接

热点排行