1

我正在尝试将 Libtorrent 与 Visual Studio 2013 静态链接,但在构建 Libtorrent 然后编译我的项目后,我不断收到这个错误:

 LINK : fatal error LNK1104: cannot open file 'libboost_system-vc120-mt-1_55.lib'

当我静态构建时,我没有libboost_system-vc120-mt-1_55.lib而是有libboost_system-vc120-mt-s-1_55.lib。我使用以下参数构建了提升:

 "toolset=msvc-12.0 variant=release link=static runtime-link=static --with-date_time --with-system --with-thread"

和 Libtorrent 与这些:

 "toolset=msvc-12.0 boost=source boost-link=static geoip=off encryption=tommath link=static dht=on logging=none statistics=off i2p=on variant=release"

当构建的 Libtorrent 认为它是共享的而不是静态的时,我缺少什么?

4

1 回答 1

2

runtime-link=static您在构建时已指定boost. 这意味着您需要libtorrent和您的应用程序(以及您可能使用的任何其他库)也静态链接到 C++ 运行时库。

因此,您需要添加runtime-link=static到构建命令行libtorrent并为您的应用程序选择适当的 VC++ 编译器选项(命令行选项或IDE下/MT的相应Runtime Library选项)。Code Generation

否则,即使你以某种方式编译了整个东西,你也会得到一些惊人的运行时错误,因为你的程序的一部分将使用运行时的静态版本,而另一部分将使用共享的。

于 2015-02-21T14:48:56.123 回答