编译时出现致命错误LNK1181如何解决

How to solve fatal error LNK1181 when compiling

我正在尝试构建 ORBSLAM2 on Windows with Visual Studio 2015 v14 x64. This particular branch of ORBSLAM2 has a dependency to the C/C++ Boost 库。

到目前为止我已经执行了以下步骤:

A.) 我按照 here:

下载并构建了 Boost 库
$ bootstrap.bat
$ b2 link=static runtime-link=static release stage
$ bjam install --toolset=msvc variant=release link=static threading=multi runtime-link=static

B.)然后我给项目配置了如下属性:

Project Properties -> C/C++ -> General -> Additional Include Directories

D:\ORB_SLAM2\Thirdparty\boost_1_64_0\

Project Properties -> Linker -> Input-> Additional Dependencies

D:\ORB_SLAM2\Thirdparty\boost_1_64_0\stage\lib\

构建时出现以下链接器错误:

1>------ Rebuild All started: Project: ZERO_CHECK, Configuration: Release x64 ------
1>  Checking Build System
1>  CMake does not need to re-run because D:/ORB_SLAM2/build/CMakeFiles/generate.stamp is up-to-date.
2>------ Rebuild All started: Project: ORB_SLAM2, Configuration: Release x64 ------
2>  Building Custom Rule D:/ORB_SLAM2/CMakeLists.txt
2>  CMake does not need to re-run because D:/ORB_SLAM2/build/CMakeFiles/generate.stamp is up-to-date.
2>  System.cc
2>  Tracking.cc
2>  LocalMapping.cc
2>  LoopClosing.cc
2>  ORBextractor.cc
...
...
...
2>  Viewer.cc
2>  Generating Code...
2>  ORB_SLAM2.vcxproj -> D:\ORB_SLAM2\build\Release\ORB_SLAM2.lib
3>------ Rebuild All started: Project: mono_euroc, Configuration: Release x64 ------
3>  mono_euroc.cc
3>LINK : fatal error LNK1181: cannot open input file 'D:\ORB_SLAM2\Thirdparty\boost_1_64_0\stage\lib\.obj'
========== Rebuild All: 2 succeeded, 1 failed, 0 skipped ==========

奇怪的是,链接器只查找.obj,没有涉及文件名。知道问题出在哪里吗?

我通过在 Visual Studio 2015 IDE.

中使用 NuGet Packet Manager 安装 Boost 库解决了这个问题
  1. 右键解决方案->Manage NuGet Packages for Solution
  2. 浏览 "boost" 和 select boost-vc140(作者:Sergey Shandar)
  3. 在右侧,select想要的版本并检查你想要的项目linkBoost
  4. 点击"Install" -> 确定 -> 稍等,耐心等待...
  5. 右键单击您的项目 -> 配置属性 -> C/C++ -> 常规 -> 附加包含目录: 添加“C:\<path-to-your-project>\build\packages\boost.1.64.0.0\lib\native\include
  6. 右键单击您的项目 -> 配置属性 -> 链接器 -> 输入 -> 附加依赖项: 添加“C:\<path-to-your-project>\build\packages\boost_serialization-vc140.1.64.0.0\lib\native\address-model-64\lib\libboost_serialization-vc140-mt-s-1_64.lib