【问题标题】:LNK1104: cannot open file 'libboost_program_options-vc100-mt-sgd-1_56.lib'LNK1104:无法打开文件“libboost_program_options-vc100-mt-sgd-1_56.lib”
【发布时间】:2014-11-01 20:16:56
【问题描述】:

尝试在 VS2010 中编译时出现此错误:

LNK1104:无法打开文件“libboost_program_options-vc100-mt-sgd-1_56.lib”

我在 stackoverflow 上阅读了许多类似的问题,但仍然无法解决。

文件“libboost_program_options-vc100-mt-gd-1_56.lib”存在,但“libboost_program_options-vc100-mt-sgd-1_56.lib”(注意 sgd 与 gd 中的 s)不在我的 lib 文件夹中。

我可能需要更改项目设置中的某些内容以摆脱 s!? 或者我需要以不同的方式编译 boost 库? 还是以上都不是……!?

我希望有人能指出我正确的方向。

也许有帮助,我正在尝试从 https://github.com/thegrandpoobah/voronoi 编译 voronoi.cpp

我下载了 Boost 1.56 并使用以下方法编译了库二进制文件:

bootstrap
.\b2

如入门文件中所述。

【问题讨论】:

  • 如何从 VS 链接 boost 库?
  • 不是静态库。所以问题在于静态库与动态库。
  • 您是否在链接器路径中将路径设置为 boost 库的位置?
  • @Piotr S. 和 Mgetz:我将编译器包含路径的路径和指向 stage/lib 文件夹的链接添加到链接器包含路径。要查看我对项目的所有设置,请参阅:screencast.com/t/ddTOEt4F2MM

标签: c++ boost


【解决方案1】:

简而言之

您正在链接静态库(因此库名称中的“s”)。可能是因为您在 Visual Studio 下“代码生成”中的“多线程”或“多线程调试”设置下生成项目。

这些库在你构建 boost 时默认不构建

b2

您需要改为运行

b2 build-type=complete

还可以生成 boost 库的静态版本。

详细介绍

在文件 boostcpp.jam 中,构建选项定义为(针对 Windows 目标):

self.minimal-properties-win = [ property-set.create <variant>debug
        <variant>release <threading>multi <link>static <runtime-link>shared
        <address-model>32 <address-model>64 ] ;

self.complete-properties = [ property-set.create
    <variant>debug <variant>release
    <threading>multi
    <link>shared <link>static
    <runtime-link>shared <runtime-link>static ] ;

self.complete-properties-win = [ property-set.create
    <variant>debug <variant>release
    <threading>multi
    <link>shared <link>static
    <runtime-link>shared <runtime-link>static
    <address-model>32 <address-model>64 ] ;

&lt;link&gt; 选项代表构建的库本身,而&lt;runtime-link&gt; 代表它们实际构建的库的类型。

因此,使用minimal-properties,您不会生成&lt;runtime-link&gt;static,而这正是您在名称后缀中使用s 所要查找的内容。

【讨论】:

    猜你喜欢
    • 2014-06-21
    • 1970-01-01
    • 1970-01-01
    • 2014-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-04
    相关资源
    最近更新 更多