[英]Visual Studio C++ how to add header files in a prefix folder
I cloned a github C++ repository.我克隆了一个 github C++ 存储库。 The repository is not a VS project.
存储库不是 VS 项目。 So I manually created a VS C++ blank project and added the files from the repo to the project.
所以我手动创建了一个 VS C++ 空白项目,并将 repo 中的文件添加到项目中。 The files are not copied.
文件不会被复制。 This is not the problem.
这不是问题。
The repo directory looks like this: repo 目录如下所示:
include\NTL\*.h
src\*.cpp
*.h
means a bunch of header files and *.cpp
means a bunch of .cpp
source files. *.h
表示一堆 header 文件, *.cpp
表示一堆.cpp
源文件。
The problem is that the .cpp
files have #include <NTL/*.h>
and when I build, VS fails to locate the header files ( No such file or directory
).问题是
.cpp
文件有#include <NTL/*.h>
并且当我构建时,VS 无法找到 header 文件( No such file or directory
)。 Adding the path to the include
to the Include Directories in project properties didn't help.将包含的路径添加到项目属性中的
include
目录没有帮助。
EDIT: After some experimenting, I've found that the error has nothing to do with the prefix
NTL
in
#include <NTL/*.h>
but with whether the files are copied into project directory.
编辑:经过一些实验,我发现该错误与
#include <NTL/*.h>
中的前缀
NTL
无关,而是与文件是否复制到项目目录中有关。
Even though the files appear in VS project view, they must be copied into the project directory.
即使文件出现在 VS 项目视图中,也必须将它们复制到项目目录中。
EDIT: The only way I've managed to get the project to compile is to put the whole
NTL
directory containing header files in project directory.
编辑:我设法编译项目的唯一方法是将包含 header 文件的整个
NTL
目录放在项目目录中。
Include Directories and Additional Include Directories in project properties don't seem to have any effect.
在项目属性中包含目录和附加包含目录似乎没有任何效果。
All previous No such file or directory
errors were the result of some combination of:所有以前的
No such file or directory
错误都是以下某些组合的结果:
.h
files were actually missing from NTL github repo, eg mach_desc.h
. .h
文件,例如mach_desc.h
。 The solution to the problem consists of the following:该问题的解决方案包括以下内容:
Properties > C/C++
, add the path to the include
to Additional Include Directories
.Properties > C/C++
下,将包含的路径include
到Additional Include Directories
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.