无法使用VS2012链接到静态升压库,而动态链接工作正常

Unable to link to static boost library using VS2012 while dynamic linking works fine

本文关键字:链接 动态 工作 VS2012 静态      更新时间:2023-10-16

我正在尝试使用 VS2012 Express 将 boost 库(boost/thread.hpp 和 boost/asio.hpp(静态链接到我的项目。生成目标设置为具有选项多线程 (/MT((静态链接(的 Windows XP (v110_xp(。提升库的路径在我的项目属性中设置正确。(C:\Boost\boost_1_54_0\stage\lib(尽管如此,我还是收到以下链接器错误:

error LNK1104: file "libboost_system-vc110-mt-s-1_54.lib" cannot be opened.

我的库文件夹中确实缺少此文件。但是,当使用多线程 DLL (/MD( 选项动态链接时,所有链接都正常。我最初使用简单的构建方法构建 boost 库,如下所述:http://www.boost.org/doc/libs/1_54_0/more/getting_started/windows.html#simplified-build-from-source

bootstrap
.b2

由于静态库明显丢失,我调用:

b2 --link=static

如下所述: http://www.boost.org/boost-build2/doc/html/bbv2/tutorial/linkage.html

这执行没有错误,但似乎没有构建任何新的东西。我错过了什么?还是VS正在寻找一个永远不存在的文件?我很惊讶,当我在谷歌上搜索错误时,只得到了一把点击,但没有一个真正有帮助。

使用以下

参数调用b2

link=static runtime-link=static

请注意,linkruntime-link 之前没有连字符。