Visual Studio在发布模式下找不到boost include文件(在调试中工作)

Visual Studio not finding boost include files in release mode (works in debug)

本文关键字:include boost 文件 调试 工作 找不到 Studio 布模式 模式 Visual      更新时间:2023-10-16

我在Visual Studio 2013 Express中使用boost。

Visual Studio在调试模式下找到#include <boost/filesystem.hpp>,而不是在发布模式下。

当我尝试在发布模式下编译时,它说:

Error 1 error C1083: Cannot open include file: 'boost/filesystem.hpp': No such file or directory

当我右键单击#include指令手动打开文件时,它在调试配置中工作,但再次不在发布中,它说:

File 'boost/filesystem.hpp' not found in current source file's directory or in build system paths.

我检查了构建配置和

  • C/c++ -> General -> "Additional Include Directories"
  • 链接器->通用-> "附加图书馆目录"
  • 链接器->输入->"附加依赖项"

在两种配置中是相同的。

我是否需要编辑"构建系统路径",如错误所说?我认为这就是上面三个选项的作用。

还有什么可能导致这个问题?

再次检查您是否检查了实际构建失败的项目的设置。我在使用boost::optional时遇到了同样的问题。我只是忽略了另一个项目(UnitTests)失败了,而不是我怀疑的项目(CppPlaygroundLib)由于误解了构建输出,专注于包含错误信息的行:

1>------ Build started: Project: UnitTests, Configuration: Release Win32 ------

1比;FooTests.cpp

1>c:projectsplaygroundcppplaygroundcppplaygroundlibfoo.h(3):致命错误C1083:无法打开include文件:'boost/optional/optional.hpp':没有这样的文件或目录

========== 构建:0成功,1失败,2最新的,0跳过 ==========

C/c++ ->General->Additional Include Directories中添加了缺失的boost路径后,我的解决方案编译成功了。

Visual Studio中的项目属性页对于这两种配置是不一样的。在属性页,只需将Configuration(左上角)设置为Release,并独立地为发布构建设置配置。