BOOST 1.35 升级到 1.43 导致 __pRawDllMain 出现链接器错误(mfc 相关)
在工作中,我们有一个 MFC 扩展 DLL,可以使用 1.35 构建,但使用 1.43 构建时会导致以下错误:
error LNK2005: __pRawDllMain already defined in ApObs.obj
如果我激活 BOOST_LIB_DIAGNOSTIC,则旧的构建列表:
linking to lib file: libboost_thread-vc71-mt-gd-1_35.lib
因此
linking to lib file: libboost_thread-vc71-mt-gd-1_43.lib
,与链接的库没有任何变化
完整的错误消息是:
libboost_thread-vc71-mt-gd-1_43.lib(tss_pe.obj) : error LNK2005: __pRawDllMain already defined in ApObs.obj
我有在两个库版本中对 tss_pe.cpp 进行了比较,它们是相同的,所以我不确定问题是什么。
您可以通过定义 BOOST_THREAD_USE_DLL
让消息消失,但是我们需要发送 BOOST_THREAD-VC71-MT-GD-1_43.DLL,所以我认为这不是最好的解决方案。
At work we have an MFC Extension DLL that built fine with 1.35 but when built with 1.43 causes the following error:
error LNK2005: __pRawDllMain already defined in ApObs.obj
If I activate BOOST_LIB_DIAGNOSTIC the old build lists:
linking to lib file: libboost_thread-vc71-mt-gd-1_35.lib
and
linking to lib file: libboost_thread-vc71-mt-gd-1_43.lib
So no change there with which library is linked
The full error message is:
libboost_thread-vc71-mt-gd-1_43.lib(tss_pe.obj) : error LNK2005: __pRawDllMain already defined in ApObs.obj
I have done a diff on tss_pe.cpp in both library versions and they are identical, so I'm not sure what the problem is.
You can get the message to disappear by defining BOOST_THREAD_USE_DLL
but then we would need to ship BOOST_THREAD-VC71-MT-GD-1_43.DLL so I don't think this is the best solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MFC 和静态链接的 boost Thread 之间存在已知的不兼容性,两者都试图挂接到 DllMain 来初始化内容。这已在 boost 1.37 中引入。
来自 boost::thread 的作者:
(不过,他建议使用 DLL 版本。)
似乎有 努力使这个修补变得不必要,但到目前为止显然没有效果......
There is known incompatibility between MFC and statically linked boost Thread, both trying to hook into DllMain to initialize stuff. This has been introduced in boost 1.37.
From the author of boost::thread:
(He recommends to use the DLL version, though.)
There seem to have been efforts to make this patching unnecessary, but apparently to no avail so far...
发生这种情况是因为链接顺序。
您可以通过在其他依赖项中手动添加库来更改链接错误。
在其他冲突的库之前放置 libboost_thread-vc71-mt-gd-1_43.lib 解决了问题:
就我而言, 属性->配置属性->链接器->输入->附加依赖项
libboost_thread-vc80-mt-1_40.lib;mfcs80u.lib;%(AdditionalDependencies)
请注意,在我的情况下它与 mfcs80u.lib 冲突
This happens because of the linking order.
You can change the linking error by manually adding the libs in the Additional Dependencies.
In my case putting libboost_thread-vc71-mt-gd-1_43.lib BEFORE the other conflicting lib solved the problem:
Project -> Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies
libboost_thread-vc80-mt-1_40.lib;mfcs80u.lib;%(AdditionalDependencies)
Note that in my case it was conflicting with mfcs80u.lib