C++ 致命错误 LNK1104:无法打开文件“libboost_system-vc110-mt-gd-1_51.lib”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13042561/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
fatal error LNK1104: cannot open file 'libboost_system-vc110-mt-gd-1_51.lib'
提问by Rushino
Seem I can't get this to work. I made a simple console application (which depend on websocket++
library) which need Boost
libraries.. but when I try to compile I get:
似乎我无法让它发挥作用。我制作了一个websocket++
需要Boost
库的简单控制台应用程序(依赖于库)。但是当我尝试编译时,我得到:
fatal error LNK1104: cannot open file 'libboost_system-vc110-mt-gd-1_51.lib'
致命错误 LNK1104:无法打开文件“libboost_system-vc110-mt-gd-1_51.lib”
However, I did the bjam which created the lib in (boost_root)/stage/libs
and I linked the path to the libs to the compiler C++/Additionnals includes
.
但是,我执行了创建 lib in 的 bjam,(boost_root)/stage/libs
并将 libs 的路径链接到了 compiler C++/Additionnals includes
。
If I look in (boost_root)/stage/libs
the file libboost_system-vc110-mt-gd-1_51.lib
is not there. It is called libboost_system-vc110-mt-sgd-1_51.lib
instead.
如果我看(boost_root)/stage/libs
文件 libboost_system-vc110-mt-gd-1_51.lib
不存在。它被称为libboost_system-vc110-mt-sgd-1_51.lib
。
Any idea?
任何的想法?
回答by Wu Jie
This is the simplest way for an amateur like me who is studying C++ on their own:
对于像我这样自学 C++ 的业余爱好者来说,这是最简单的方法:
First Unzip the boost library to any directory of your choice. I recommend c:\directory
.
首先将 boost 库解压缩到您选择的任何目录。我推荐c:\directory
。
- Open your visual C++.
- Create a new project.
- Right click on the project.
- Click on property.
- Click on C/C++.
- Click on general.
- Select additional include library.
- Include the library destination. e.g.
c:\boost_1_57_0
. - Click on pre-compiler header.
- Click on create/use pre-compiled header.
- Select not using pre-compiled header.
- 打开你的可视化 C++。
- 创建一个新项目。
- 右键单击项目。
- 点击属性。
- 单击 C/C++。
- 点击一般。
- 选择其他包含库。
- 包括库目标。例如
c:\boost_1_57_0
。 - 单击预编译器头文件。
- 单击创建/使用预编译头。
- 选择不使用预编译头。
Then go over to the link library were you experienced your problems.
如果您遇到问题,请转到链接库。
- Go to were the extracted file was
c:\boost_1_57_0
. - Click on
booststrap.bat
(don't bother to type on the command window just wait and don't close the window that is the place I had my problem that took me two weeks to solve. After a while thebooststrap
will run and produce the same file, but now with two different names:b2
, andbjam
. - Click on
b2
and wait it to run. - Click on
bjam
and wait it to run. Then a folder will be produce calledstage
. - Right click on the project.
- Click on property.
- Click on linker.
- Click on general.
- Click on include additional library directory.
- Select the part of the library e.g.
c:\boost_1_57_0\stage\lib
.
- 转到提取的文件是
c:\boost_1_57_0
. - 单击
booststrap.bat
(不要费心在命令窗口上键入,只需等待,不要关闭窗口,该窗口是我遇到问题的地方,我花了两周时间才解决。过了一会儿,booststrap
将运行并生成相同的文件,但现在有两个不同的名称:b2
, 和bjam
。 - 单击
b2
并等待它运行。 - 单击
bjam
并等待它运行。然后将生成一个名为stage
. - 右键单击项目。
- 点击属性。
- 单击链接器。
- 点击一般。
- 单击包括附加库目录。
- 选择库的一部分,例如
c:\boost_1_57_0\stage\lib
。
And you are good to go!
你很高兴去!
回答by Praetorian
The C++ → General → Additional Include Directoriesparameter is for listing directories where the compiler will search for header files.
在C ++→常规→附加包含目录参数是列出目录编译器将头文件搜索。
You need to tell the linker where to look for libraries to link to. To access this setting, right-click on the project name in the Solution Explorerwindow, then Properties → Linker → General → Additional Library Directories. Enter <boost_path>\stage\lib
here (this is the path where the libraries are located if you build Boostusing default options).
您需要告诉链接器在哪里查找要链接到的库。要访问此设置,请右键单击“解决方案资源管理器”窗口中的项目名称,然后单击“属性”→“链接器”→“常规”→“附加库目录”。<boost_path>\stage\lib
在此处输入(这是使用默认选项构建 Boost 时库所在的路径)。
回答by Jota Santos
I had the same problem. It was caused because I compiled the Boost with the Visual C++ 2010(v100) and I tried to use the library with the Visual Studio 2012 (v110) by mistake.
我有同样的问题。这是因为我使用 Visual C++ 2010(v100) 编译了 Boost,并且我错误地尝试将库与 Visual Studio 2012 (v110) 一起使用。
So, I changed the configurations (in Visual Studio 2012) going to Project properties-> General-> Plataform Toolsetand change the value from Visual Studio 2012 (v110)to Visual Studio 2010 (v100).
因此,我将配置(在 Visual Studio 2012 中)更改为Project properties-> General-> Plataform Toolset并将值从Visual Studio 2012 (v110)更改为Visual Studio 2010 (v100)。
回答by wdtj
Yet another solution:
另一个解决方案:
I was stumped because I was including boost_regex-vc120-mt-gd-1_58.lib in my Link->Additional Dependencies property, but the link kept telling me it couldn't open libboost_regex-vc120-mt-gd-1_58.lib (note the lib prefix). I didn't specify libboost_regex-vc120-mt-gd-1_58.lib.
我被难住了,因为我在 Link->Additional Dependencies 属性中包含了 boost_regex-vc120-mt-gd-1_58.lib,但该链接一直告诉我它无法打开 libboost_regex-vc120-mt-gd-1_58.lib(请注意 lib 前缀)。我没有指定 libboost_regex-vc120-mt-gd-1_58.lib。
I was trying to use (and had built) the boost dynamic libraries (.dlls) but did not have the BOOST_ALL_DYN_LINK macro defined. Apparently there are hints in the compile to include a library, and without BOOST_ALL_DYN_LINK it looks for the static library (with the lib prefix), not the dynamic library (without a lib prefix).
我试图使用(并已构建)boost 动态库 (.dll),但没有定义 BOOST_ALL_DYN_LINK 宏。显然,编译中有包含库的提示,如果没有 BOOST_ALL_DYN_LINK,它会查找静态库(带有 lib 前缀),而不是动态库(没有 lib 前缀)。
回答by Plinio
I had the same problem and my mistake was that I had installed the binary boost_1_55_0-msvc-11.0-32.exe to use with visual c++ 2010 which has the version v100 (project properties->ConfiguratioProperties->General->platformTooset) not v110 as visual c++ 2012. So I dowloaded boost_1_55_0-msvc-10.0-32.exe and now everything is ok so far.
我遇到了同样的问题,我的错误是我安装了二进制 boost_1_55_0-msvc-11.0-32.exe 以与版本 v100(项目属性->ConfiguratioProperties->General->platformTooset)而不是 v110 的 Visual c++ 2010 一起使用作为visual c++ 2012。所以我下载了boost_1_55_0-msvc-10.0-32.exe,现在一切正常。
回答by Bob Bryan
In case you have trouble building boost or prefer not to do that, an alternative is to download the lib files from SourceForge. The link will take you to a folder of zipped lib and dll files for version 1.51. But, you should be able to edit the link to specify the version of choice. Apparently the installer from BoostPro has some issues.
如果您在构建 boost 时遇到问题或不想这样做,另一种方法是从SourceForge下载 lib 文件。该链接会将您带到一个包含 1.51 版的压缩 lib 和 dll 文件的文件夹。但是,您应该能够编辑链接以指定选择的版本。显然 BoostPro 的安装程序存在一些问题。
回答by Aciel
I had a similar problem when trying to use boost unit testingin Visual Studio 2015(Community Edition):
我在Visual Studio 2015(社区版)中尝试使用boost 单元测试时遇到了类似的问题:
fatal error LNK1104: libboost_unit_test_framework-vc140-mt-1_57
致命错误 LNK1104:libboost_unit_test_framework-vc140-mt-1_57
so I thought I'd share my solution.
所以我想我会分享我的解决方案。
You can create a boost unit testing project in of of two ways (and this solution works for both):
您可以通过以下两种方式创建一个 boost 单元测试项目(此解决方案适用于这两种方式):
- using the Boost Unit Test Adapter
- or by creating a Win32 Console Application (steps here), and substituting the main function with a boost unit testing function (steps here).
- 使用Boost 单元测试适配器
- 或者通过创建一个 Win32 控制台应用程序(此处的步骤),并用一个 boost 单元测试功能(此处的步骤)替换主函数。
Here are the steps I followed to get both projects to work:
以下是我为使两个项目都能正常工作而遵循的步骤:
First, download the desired boost version (for example, boost_1_57_0). You can either download boost with the correct binaries (compiled using msvc v140), or extract the binaries yourself by running the following commands from command line:
首先,下载所需的 boost 版本(例如boost_1_57_0)。您可以使用正确的二进制文件(使用 msvc v140 编译)下载 boost,也可以通过从命令行运行以下命令自行提取二进制文件:
- bootstrap.bat
- "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
- bjam --clean
- bjam -j4 --debug-symbols=on --build-type=complete toolset=msvc-14.0 threading=multi runtime-link=shared address-model=32
- 引导程序.bat
- "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
- bjam --clean
- bjam -j4 --debug-symbols=on --build-type=complete toolset=msvc-14.0 threading=multi runtime-link=shared address-model=32
Where msvc-14.0specifies that we require the Visual Studio 2015 version (VS 2015 = v14.0 = v140), and address-model=32specifies that we require platform 32 (but the same can be done for 64 bit).
其中msvc-14.0指定我们需要 Visual Studio 2015 版本(VS 2015 = v14.0 = v140),address-model=32指定我们需要平台 32(但对于 64 位也可以这样做)。
Once you have the binaries, go to Visual Studio, select the Boost Unit Testing project you have created. Go to Project properties > configuration(from the main menu) and make the following choices:
获得二进制文件后,转到 Visual Studio,选择您创建的 Boost 单元测试项目。转到项目属性 > 配置(从主菜单)并进行以下选择:
Set the "General > Platform Toolset" to Visual Studio 2015 (v140).
Include the path to the boost folder (e.g. C:\boost_1_57_0) and the path to the subfolder containing the binary files (e.g. C:\boost_1_57_0\stage\lib) in:
- "C\C++ > Additional Include Directory"
- and "Linker > Additional Library Directories".
将“ General > Platform Toolset”设置为 Visual Studio 2015 (v140)。
包括 boost 文件夹的路径(例如 C:\boost_1_57_0)和包含二进制文件的子文件夹的路径(例如 C:\boost_1_57_0\stage\lib):
- “ C\C++ > 附加包含目录”
- 和“链接器 > 附加库目录”。
回答by fiorentinoing
I had same issue reported here. I solved the issue moving the mainTest.cpp from a subfolder src/mainTest/ to the main folder src/ I guess this was your problem too.
我在这里报告了同样的问题。我解决了将 mainTest.cpp 从子文件夹 src/mainTest/ 移动到主文件夹 src/ 的问题,我想这也是您的问题。
回答by kevinf
2>LINK : fatal error LNK1104: cannot open file 'libboost_regex-vc120-mt-sgd-1_55.lib
2>LINK : fatal error LNK1104: cannot open file 'libboost_regex-vc120-mt-sgd-1_55.lib
In my case, bootstrap/bjam was not available (libraries were precompiled and committed to SCM) on old inherited project. Libraries did not have VC or BOOST versioning in their filenames eg: libboost_regex-mt-sgd.lib
, however Processed /DEFAULTLIB:libboost_regex-vc120-mt-sgd-1_55.lib
was somehow triggered automatically.
就我而言,在旧的继承项目上,bootstrap/bjam 不可用(库已预编译并提交给 SCM)。库的文件名中没有 VC 或 BOOST 版本控制,例如: libboost_regex-mt-sgd.lib
,但是Processed /DEFAULTLIB:libboost_regex-vc120-mt-sgd-1_55.lib
以某种方式自动触发。
Fixed by manually adding the non-versioned filename to:
通过手动添加非版本化文件名来修复:
<AdditionalDependencies>$(DK_BOOST)\lib64\libboost_regex-mt-sgd.lib</AdditionalDependencies>
and blacklisting the ...vc120-mt-sgd-1_55.lib
in
而在黑名单...vc120-mt-sgd-1_55.lib
中
<IgnoreSpecificDefaultLibraries>libboost_regex-vc120-mt-sgd-1_55.lib</IgnoreSpecificDefaultLibraries>
回答by Dmitry Ivanov
b2 -j%cores% toolset=%msvcver% address-model=64 architecture=x86 link=static threading=multi runtime-link=shared --build-type=minimal stage --stagedir=stage/x64
b2 -j%cores% 工具集=%msvcver% address-model=64 architecture=x86 link=static threading=multi runtime-link=shared --build-type=minimal stage --stagedir=stage/x64
Properties → Linker → General → Additional Library Directories $(BOOST)\stage\x64\lib
属性 → 链接器 → 常规 → 附加库目录 $(BOOST)\stage\ x64\lib