求解linux下链接boost库问题,急,在线等
现做一个项目用到mongodb,其调用boost库,编译时报错如下:../lib/libmongoclient.a(json.o):Infunction`mutex':/...
现做一个项目用到mongodb,其调用boost库,编译时报错如下:
../lib/libmongoclient.a(json.o): In function `mutex':
/opt/boost/include/boost/thread/pthread/mutex.hpp:40: undefined reference to `boost::thread_resource_error::thread_resource_error()'
/opt/boost/include/boost/thread/pthread/mutex.hpp:40: undefined reference to `boost::thread_resource_error::thread_resource_error()'
/opt/boost/include/boost/thread/pthread/mutex.hpp:40: undefined reference to `boost::thread_resource_error::thread_resource_error()'
/opt/boost/include/boost/thread/pthread/mutex.hpp:40: undefined reference to `boost::thread_resource_error::thread_resource_error()'
/opt/boost/include/boost/thread/pthread/mutex.hpp:40: undefined reference to `boost::thread_resource_error::thread_resource_error()'
../lib/libmongoclient.a(nonce.o):/opt/boost/include/boost/thread/pthread/mutex.hpp:40: more undefined references to `boost::thread_resource_error::thread_resource_error()' follow
collect2: ld returned 1 exit status
编译命令为:g++ main.cpp -I../include -L../lib -lmongoclient -L/usr/local/lib -lboost_thread -lboost_filesystem -lboost_program_options -o main
而我单独调用mutex.hpp时是不报错的,哪位大虾能给小弟一些指导,困惑了好几天了,东西急等着用呢 展开
../lib/libmongoclient.a(json.o): In function `mutex':
/opt/boost/include/boost/thread/pthread/mutex.hpp:40: undefined reference to `boost::thread_resource_error::thread_resource_error()'
/opt/boost/include/boost/thread/pthread/mutex.hpp:40: undefined reference to `boost::thread_resource_error::thread_resource_error()'
/opt/boost/include/boost/thread/pthread/mutex.hpp:40: undefined reference to `boost::thread_resource_error::thread_resource_error()'
/opt/boost/include/boost/thread/pthread/mutex.hpp:40: undefined reference to `boost::thread_resource_error::thread_resource_error()'
/opt/boost/include/boost/thread/pthread/mutex.hpp:40: undefined reference to `boost::thread_resource_error::thread_resource_error()'
../lib/libmongoclient.a(nonce.o):/opt/boost/include/boost/thread/pthread/mutex.hpp:40: more undefined references to `boost::thread_resource_error::thread_resource_error()' follow
collect2: ld returned 1 exit status
编译命令为:g++ main.cpp -I../include -L../lib -lmongoclient -L/usr/local/lib -lboost_thread -lboost_filesystem -lboost_program_options -o main
而我单独调用mutex.hpp时是不报错的,哪位大虾能给小弟一些指导,困惑了好几天了,东西急等着用呢 展开
1个回答
展开全部
很明显是你链接的库还不够,boost的thread要链接静态库的,仔细找找你的链接目录吧
参考资料: http://www.boost.org/doc/libs/
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询