win7 codeblock在调用boost::thread遇到的错误——解决办法
来源:互联网 发布:淘宝网店收费 编辑:程序博客网 时间:2024/06/05 16:46
转载:http://www.cnblogs.com/flywuya/archive/2010/11/30/1892524.html
使用boost::thread库时可能会碰到如下错误 (Linux下 gcc4.4+boost1.40)
||=== testthread, Release ===|
obj/Release/main.o||In function `main':|
main.cpp|| undefined reference to `boost::thread::join()'|
main.cpp|| undefined reference to `boost::thread::join()'|
main.cpp|| undefined reference to `boost::thread::~thread()'|
main.cpp|| undefined reference to `boost::thread::~thread()'|
main.cpp|| undefined reference to `boost::thread::~thread()'|
main.cpp|| undefined reference to `boost::thread::~thread()'|
obj/Release/main.o||In function `boost::detail::thread_data<void (*)()>::~thread_data()':|
::~thread_data()]+0x14)||undefined reference to `boost::detail::thread_data_base::~thread_data_base()'|
obj/Release/main.o||In function `boost::detail::thread_data<void (*)()>::~thread_data()':|
::~thread_data()]+0x11)||undefined reference to `boost::detail::thread_data_base::~thread_data_base()'|
obj/Release/main.o||In function `boost::thread::thread<void (*)()>(void (*)(), boost::disable_if<boost::is_convertible<void (*&)(), boost::detail::thread_move_t<void (*)()> >, boost::thread::dummy*>::type)':|
::type)]+0x4b)||undefined reference to `vtable for boost::detail::thread_data_base'|
::type)]+0x166)||undefined reference to `boost::thread::start_thread()'|
::type)]+0x18a)||undefined reference to `boost::thread_resource_error::thread_resource_error()'|
::type)]+0x192)||undefined reference to `boost::thread_resource_error::~thread_resource_error()'|
::type)]+0x19a)||undefined reference to `typeinfo for boost::thread_resource_error'|
::type)]+0x1ba)||undefined reference to `boost::thread_resource_error::thread_resource_error()'|
::type)]+0x1c2)||undefined reference to `boost::thread_resource_error::~thread_resource_error()'|
::type)]+0x1ca)||undefined reference to `typeinfo for boost::thread_resource_error'|
::type)]+0x1eb)||undefined reference to `boost::thread_resource_error::thread_resource_error()'|
::type)]+0x1f6)||undefined reference to `boost::thread_resource_error::~thread_resource_error()'|
::type)]+0x1fe)||undefined reference to `typeinfo for boost::thread_resource_error'|
::type)]+0x223)||undefined reference to `boost::thread_resource_error::thread_resource_error()'|
::type)]+0x22e)||undefined reference to `boost::thread_resource_error::~thread_resource_error()'|
::type)]+0x236)||undefined reference to `typeinfo for boost::thread_resource_error'|
::type)]+0x25b)||undefined reference to `boost::thread_resource_error::thread_resource_error()'|
::type)]+0x266)||undefined reference to `boost::thread_resource_error::~thread_resource_error()'|
::type)]+0x26e)||undefined reference to `typeinfo for boost::thread_resource_error'|
]+0x8)||undefined reference to `typeinfo for boost::detail::thread_data_base'|
||=== Build finished: 26 errors, 0 warnings (0 minutes, 3 seconds) ===|
或者以下错误 (windows gcc4.5+boost1.45)
C:\Boost_1_45\include\boost-1_45\boost\thread\win32\thread_heap_alloc.hpp|59|warning: inline function 'void* boost::detail::allocate_raw_heap_memory(unsigned int)' declared as dllimport: attribute ignored|
C:\Boost_1_45\include\boost-1_45\boost\thread\win32\thread_heap_alloc.hpp|69|warning: inline function 'void boost::detail::free_raw_heap_memory(void*)' declared as dllimport: attribute ignored|
obj\Debug\main.o:main.cpp:(.text$_ZN5boost12thread_groupD1Ev[boost::thread_group::~thread_group()]+0x77)||undefined reference to `_imp___ZN5boost6threadD1Ev'|
obj\Debug\main.o:main.cpp:(.text$_ZN5boost12thread_group8join_allEv[boost::thread_group::join_all()]+0x87)||undefined reference to `_imp___ZN5boost6thread4joinEv'|
::type)]+0x58)||undefined reference to `_imp___ZN5boost6thread12start_threadEv'|
::type)]+0x55)||undefined reference to `_imp___ZN5boost6thread12start_threadEv'|
::~auto_ptr()]+0x14)||undefined reference to `_imp___ZN5boost6threadD1Ev'|
||=== Build finished: 5 errors, 2 warnings (0 minutes, 5 seconds) ===|
以上错误是由于未导入thread的静态链接库,解决方法如下
如果使用boost::thread,使用静态链接时 即编译boost库时使用选项link=static runtime-link=static
对于ubuntu下,需要在project的build options中linker settings--》other linker options中添加-lboost_thread
对于windows下,需要在project的build options中linker settings--》link libraries中添加boost_1_45\lib\libboost_thread-mgw45-mt-1_45.a(注意,debug和release要田间对应的库文件),并修改头文件(boost_1_45\include\boost_1_45\boost\thread\detail\config.hpp)中第40行,在末尾添加宏 || defined(MINGW32),同时在build options中compiler settings中的#defines添加MINGW32或者一劳永逸地在全局设定中添加此宏(settings-->compiler and debugger-->compiler settings-->#defines中添加红MINGW32)
使用动态链接库时,即编译boost库时使用选项link=shared runtime-link=shared
对于windows下,需要在project的build options中linker settings--》link libraries中添加boost_1_45\lib\libboost_thread-mgw45-mt-1_45-dll.a(注意,debug和release要田间对应的库文件),并将此dll文件拷贝到编译的可执行程序根目录下
- win7 codeblock在调用boost::thread遇到的错误——解决办法
- CodeBlock編译boost thread程序
- 链接 boost thread 错误 _pRawDllMain 已定义解决办法
- 记: 在调试boost::thread库遇到的一个小问题
- thread——MFC下Boost的线程编译错误问题
- nutch研究—遇到的错误和解决办法
- WIN7 错误711的解决办法
- 安装win7 SP1后或者安装其他补丁后,在应用更新操作第XXX个文件时候遇到致命错误的解决办法
- Build Boost 遇到错误
- codeblock异常关闭,重新开机,启动时提示有另外的实例在运行的解决办法。
- 【Boost】boost库中thread多线程详解11——线程的休眠和中断
- 【Boost】boost库中thread多线程详解12——线程的分离与非分离
- BOOST库的thread
- win7 打开共享目录提示 —— 登陆失败:未知的用户名或密码错误解决办法
- 在Win7中创建、部署WebService时遇到的访问被拒绝错误解决方法
- Win7下MingW编译Boost Asio程序的错误解决方法
- win7系统在启动MySQL Query Browser时出现的Error2003错误及解决办法
- codeblocks+wxwidgets+boost搭建c++开发平台步骤||如何在CodeBlock中添加boost库文件
- Window 对象
- 利用递归求n以内的素数之和
- 位操作-leetcode 401. Binary Watch
- Android中EditText限制仅允许输入汉字/仅允许汉字和数字
- 百度ueditor富文本--PC端单个,PC端多个,mobile单个,mobile多个
- win7 codeblock在调用boost::thread遇到的错误——解决办法
- 我的第一个Hbuilder项目(WEB)
- 照片人脸建模
- Linux 升级 Python 至 3.x
- 我的第一个hbuilder项目
- You may need an appropriate loader to handle this file type
- 不同字符编码转换(UTF8 UNICODE ANSI)
- 基于HTML5的五子棋游戏
- mysql多个TimeStamp设置