【问题标题】:Unable to link to static boost library using VS2012 while dynamic linking works fine无法使用 VS2012 链接到静态 boost 库,而动态链接工作正常
【发布时间】:2013-10-07 13:59:04
【问题描述】:

我正在尝试使用 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 正在寻找一个永远不存在的文件?当我在谷歌上搜索错误时,我很惊讶地只得到了少数几个点击,而且没有一个真正有帮助。

【问题讨论】:

  • 如果我没有完全关闭,使用 --link=static 只是告诉 Boost 构建过程静态链接其 DLL,而不是实际创建静态库。

标签: c++ visual-studio-2012 boost static-linking


【解决方案1】:

使用以下参数调用b2

link=static runtime-link=static

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

【讨论】:

    猜你喜欢
    • 2020-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-02
    • 1970-01-01
    相关资源
    最近更新 更多