最近学习使用boost::thread库,运行事例出现错误,内容大致是:
undefined reference to `boost::thread::join()'
undefined reference to `boost ::trhead::~thread()'
......
collect2: ld return 1
.......
应该是编译的时候没有把boost库链接上
我使用的系统是ubuntu12.04,装的boost版本是1.46.1,库在/usr/lib下 libboost_thread.so.1.46.1
创建一个软连接 ln -s libboost_thread.1.46.1.so libboost_thread.so.1.46.1
g++ 的时候把 -lboost_thread.1.46.1 加上,编译就通过了。
备注:
自己把libboost_thread.so.1.46.1当成创建的软连接给删了
上http://packages.ubuntu.com/ keyword搜索thread ,Distribution选择 precise(精确查找)
选择对应我系统的 “软件包libboost-thread1.46.1” deb包,下载安装就恢复了。
愿这点小经验对大家有帮助。