c++ - LNK1104 : cannot open file 'libboost_program_options-vc100-mt-sgd-1_56.lib'

标签 c++ boost

尝试在 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

如入门文件中所述。

最佳答案

简而言之

您正在链接静态库(因此库名称中的“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 ] ;

<link> options 代表构建的库本身,而 <runtime-link>代表它们实际构建后的库类型。

所以 minimal-properties , 你不生成 <runtime-link>static ,这就是您要使用 s 查找的内容在名称后缀中。

关于c++ - LNK1104 : cannot open file 'libboost_program_options-vc100-mt-sgd-1_56.lib' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25727178/

相关文章:

c++ - 通过类函数添加到指针 vector

c++ - Libmosquitto 发布不会将所有消息传递到 Azure IoT 中心

linux - "Compiler threading support is not turned on."

c++ - Boost.Asio 套接字被阻止

c++ - 将数组的一个元素与整个另一个数组元素进行比较

c++ - 什么会导致连接卡在 close_wait 状态

c++ - 使用 boost 库在我的 PC 中获取我的以太网设备 IP 地址列表

c++ - 在 Visual Studio 2010 中使用 boost::test - 如何查看测试输出?

c++ - boost::shared_ptr 和 std::shared_ptr 共存

c++ - boost asio tcp 异步读/写