C++ 致命错误 LNK1104:无法打开文件“libboost_system-vc90-mt-gd-1_43.lib”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2889394/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 11:23:45  来源:igfitidea点击:

fatal error LNK1104: cannot open file 'libboost_system-vc90-mt-gd-1_43.lib'

c++visual-studioboost

提问by Poni

Made a new project, added main.cpp and wrote the code at this URL:

创建了一个新项目,添加了 main.cpp 并在此 URL 处编写了代码:

http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/example/echo/async_tcp_echo_server.cpp

http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/example/echo/async_tcp_echo_server.cpp

Also, added the appropriate include path.

此外,添加了适当的包含路径。

What's next?!?!! It seems like a darn mystery to build a boost code!

下一步是什么?!?!!构建一个 boost 代码似乎是个谜!

Been digging on it for more than 10 hours.

已经挖了10多个小时了。

Can anyone give a straightforward answer on how to build the boost library from the code under windows, VC9?

任何人都可以直接回答如何从 Windows VC9 下的代码构建 boost 库吗?

采纳答案by bogertron

You need to use bjam. It is responsible for creating the libraries that your application will use. Once you use bjam, you are going to need to instruct your project to include the lib file. You do this by going into the project's properties -> Configuration Properties -> Linker -> General. Add the directory which created the lib file to Additional Library Directories. You should be capable of correctly linking after that. I believe that this linkdescribes the steps better than I could attempt in a post

你需要使用 bjam。它负责创建您的应用程序将使用的库。使用 bjam 后,您将需要指示您的项目包含 lib 文件。您可以通过进入项目的属性 -> 配置属性 -> 链接器 -> 常规来完成此操作。将创建 lib 文件的目录添加到其他库目录。之后您应该能够正确链接。我相信此链接比我在帖子中尝试更能描述这些步骤

回答by Poni

@bogertron: I want to hug you! (:

@bogertron:我想拥抱你!(:

So, at last, with a real head ache, I've managed to do so.

所以,最后,带着真正的头痛,我设法做到了。

The exact steps I took, so others will be saved from the head ache:

我采取的确切步骤,因此其他人将免于头痛:

  1. Went to http://www.boost.org/doc/libs/1_43_0/more/getting_started/windows.html#or-build-binaries-from-source.

  2. Followed the "5.3.1 Get bjam" clause. Downloaded the "pre-built bjam executable for your platform" at this URL: http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=72941.

  3. Extracted the ZIP file (my platform is Windows).

  4. Ran "build.bat". It produced the file "bin.ntx86/bjam.exe".

  5. Copied this file to my PATH ("...../boost_1_43_0/").

  6. From a command line, executed "bjam.exe" and waited for about 4-5 minutes.

  1. 去了http://www.boost.org/doc/libs/1_43_0/more/getting_started/windows.html#or-build-binaries-from-source

  2. 遵循“5.3.1 Get bjam”条款。在以下 URL 下载了“为您的平台预先构建的 bjam 可执行文件”:http: //sourceforge.net/project/showfiles.php? group_id=7586&package_id=72941 。

  3. 解压缩 ZIP 文件(我的平台是 Windows)。

  4. 运行“build.bat”。它产生了文件“bin.ntx86/bjam.exe”。

  5. 将此文件复制到我的路径(“...../boost_1_43_0/”)。

  6. 从命令行,执行“bjam.exe”并等待大约 4-5 分钟。

Then got this message at the console: "The Boost C++ Libraries were successfully built!"

然后在控制台收到此消息:“Boost C++ 库已成功构建!”

That's it, it even tells you where the include & lib files are.

就是这样,它甚至会告诉您包含和 lib 文件的位置。

回答by Georg Fritzsche

Not all Boost libraries are header only, Boost.System is one of them. The documentationfor Boost.Asio tells you that it depends on Boost.System.

并非所有 Boost 库都只有头文件,Boost.System 就是其中之一。Boost.Asio的文档告诉你它依赖于 Boost.System。

With Visual Studio, the Boost libraries use auto-linking, which means you don't have to explicitly link to the libraries you need. You however need to have the necessary libraries in the library search path, either globally or per-project.

对于 Visual Studio,Boost 库使用自动链接,这意味着您不必显式链接到所需的库。但是,您需要在库搜索路径中具有必要的库,无论是全局的还是每个项目的。

If you don't want to build the Boost libraries yourself, you can use the installersprovided by boostpro (only up to Boost 1.42 though at the moment). If you want to build them yourself instead, the documentationcovers that well.

如果您不想自己构建 Boost 库,您可以使用boostpro 提供的安装程序(尽管目前最多 Boost 1.42)。如果您想自己构建它们,文档可以很好地涵盖这一点。

回答by Cracker

I had the same error and i followed the SourceForge. The link will take you to a folder of zipped lib and dll files for version of boost.You can download and unzip related library and when copied it to the related location everything gonna be alright ;)

我有同样的错误,我遵循了SourceForge。该链接将带您到一个包含用于 boost 版本的压缩 lib 和 dll 文件的文件夹。您可以下载并解压缩相关库,将其复制到相关位置后,一切都会好起来的;)

回答by user1313969

From the "Boost Getting Started Directions":

来自“Boost 入门指南”:

"5.2 Or, Simplified Build From Source

"5.2 或者,从源代码简化构建

If you wish to build from source with Visual C++, you can use a simple build procedure described in this section. Open the command prompt and change your current directory to the Boost root directory. Then, type the following commands:

如果您希望使用 Visual C++ 从源代码构建,您可以使用本节中描述的简单构建过程。打开命令提示符并将当前目录更改为 Boost 根目录。然后,键入以下命令:

bootstrap .\b2"

引导程序 .\b2"

On Windows, I opened the Visual Studio Command Line from the start menu. First I types "bootstrap" and then I typed ".\b2".

在 Windows 上,我从开始菜单打开了 Visual Studio 命令行。我首先输入“bootstrap”,然后输入“.\b2”。

回答by Sharad Salvi

In Visual Studio, right-click on your project, then go to properties and select:

在 Visual Studio 中,右键单击您的项目,然后转到属性并选择:

Properties -> Configuration Properties -> Linker

属性 -> 配置属性 -> 链接器

There you add the full path of your library in the tab named "Additional Library Directories".

您可以在名为“其他库目录”的选项卡中添加库的完整路径。

回答by sadjoker

Now with boost_1.50 the Boost.build is included in the zip file: check tools\build\v2\or better read: ...boost_1_50_0/more/getting_started/windows.html

现在使用 boost_1.50,Boost.build 包含在 zip 文件中:检查 tools\build\v2\或更好地阅读:...boost_1_50_0/more/getting_started/windows.html