我正在尝试使用 VS2012 Express 将 boost 库(boost/thread.hpp 和 boost/asio.hpp)静态链接到我的项目。构建目标设置为 Windows XP (v110_xp),并带有选项多线程 (/MT)(静态链接)。我的项目属性中正确设置了 boost 库的路径。 (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
请注意,link
和 runtime-link
之前没有连字符。
关于c++ - 无法使用 VS2012 链接到静态 boost 库,而动态链接工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19226844/