thread——MFC下Boost的线程编译错误问题
来源:互联网 发布:方维p2p 3.5 源码下载 编辑:程序博客网 时间:2024/06/04 00:23
在MFC中使用boost的多线程库,可能会抛出链接错误:
__pRawDllMain already defined in ....
这是由于thread的源码中叶有一个入口函数
extern BOOL (WINAPI * const _pRawDllMain)(HANDLE, DWORD, LPVOID)=&dll_callback;
解决方法是将
boost/libs/thread/src/win32/tss_pe.cpp
中的这句话注释然后重新编译即可解决。
网上看到另一种方法,经测试失败,如果测试成功请告之
链接:http://www.juicydata.com/LinkingMfcAndBoostThread
原文如下:
Linking against Boost can sometimes be tricky, as a minor misconfiguration in your project / makefiles can cause the auto-link mechanism to operate differently than you expect. Here's one example of a failure during link:
libboost_thread-vc80-mt-1_40.lib(tss_pe.obj) : error LNK2005: __pRawDllMain already defined in mfcs80.lib(rawdllmainproxy.obj) Creating library c:\Work\MyLib\Release\MyLib.lib and object c:\Work\MyLib\Release\MyLib.exp.\Release\MyLib.dll : fatal error LNK1169: one or more multiply defined symbols found
In this example, MFC already defines this symbol to do it's own setup during dll load or attach. The Boost::Thread library tries to do the same, with the laudable intent to initialize or teardown everything correctly. Only one actor can use this mechanism, so we'll have to modify one.
Option 1: Cause the boost thread library to be used dynamically. The preprocessor definition BOOST_ALL_DYN_LINK can be used to force all boost libraries to be used dynamically. Note that the define BOOST_LIB_DIAGNOSTIC can be used to get more info for debugging the build process.
Option 1 (continued): If you want to explicitly select libraries to link against dynamically, use preprocessor def's such as: BOOST_DATE_TIME_DYN_LINK, or BOOST_REGEX_DYN_LINK.Nota bene: For the Boost::Thread library, the define is incorrectly BOOST_THREAD_DYN_DLL instead of BOOST_THREAD_DYN_LINK. This bug was fixed around May 2010.
Option 2: Remove MFC. Do you really need MFC?
当然,最好是这里的option2 开发前先思考一下,真的必须用MFC吗?
- thread——MFC下Boost的线程编译错误问题
- 解决MFC下线程创建的一个编译错误
- 关于MFC下使用MTL库编译错误的问题
- 【Boost】boost库中thread多线程详解11——线程的休眠和中断
- 【Boost】boost库中thread多线程详解12——线程的分离与非分离
- (原创)boost中thread库的编译
- Win7下MingW编译Boost Asio程序的错误解决方法
- win7 codeblock在调用boost::thread遇到的错误——解决办法
- MFC动态库使用boost::thread运行时报错的问题
- MFC动态库使用boost::thread运行时报错的问题
- boost::thread线程管理
- boost::thread线程管理
- boost::thread线程管理
- mingw编译boost库之thread工程相关错误
- 【Boost】boost库中thread多线程详解5——谈谈线程中断
- 【Boost】boost库中thread多线程详解6——线程组简单例子
- 【Boost】boost库中thread多线程详解5——谈谈线程中断
- 【Boost】boost库中thread多线程详解6——线程组简单例子
- 关于resizableImageWithCapInsets的很好的解释
- linux hash_map
- 创业初期准备
- Linux 将命令所得的结果导入到文件
- C++中的hash_map——Linux下g++和Windows下VC++下头文件,命名空间
- thread——MFC下Boost的线程编译错误问题
- 杭电 1019 简单数学题
- struct timeval和gettimeofday()
- 又一种design pattern —— 局部整体化设计模式
- 专注于操作系统24之boot,loader,kernel
- ural 1207 计算几何
- CSDN10大博客栏目火热评选中
- Oracle 内存 架构 详解
- 软件架构