C++ “错误 C1083:无法打开包含文件”但我有包含文件的路径
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19329104/
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
"Error C1083: Cannot open include file" but I have a path to the include file
提问by sigil
Related to this question, I have included a header file in the code for a console app that I'm using to test a DLL, but Visual Studio is returning the following error:
与此问题相关,我在用于测试 DLL 的控制台应用程序的代码中包含了一个头文件,但 Visual Studio 返回以下错误:
error C1083: Cannot open include file: 'myProject.h': No such file or directory
But I have included the folder path for myProject.h
in Additional Include Directories. I also tried entering it under Configuration Properties->Debugging->Environment as a "PATH=<...>" value. The path is: U:\Software Development\c++ projects\myProject\myProject
, and when I go to that folder, I can see myProject.h
in the folder.
但是我已经myProject.h
在附加包含目录中包含了文件夹路径。我还尝试在 Configuration Properties->Debugging->Environment 下输入它作为“PATH=<...>”值。路径是: U:\Software Development\c++ projects\myProject\myProject
,当我转到该文件夹时,我可以myProject.h
在文件夹中看到。
#include "stdafx.h"
#include <iostream>
#include "myProject.h"
using namespace std;
int main()
{
cout << myProject::FileOperator::openDoc(1799,29);
}
When I type "#include", the Intellisense shows me just 3 items: the Debug folder corresponding to U:\Software Development\c++ projects\myProject\myProject\Debug
,stdafx.h
, and targetver.h
.
当我输入“#包括”智能感知显示我只有3项:Debug文件夹对应U:\Software Development\c++ projects\myProject\myProject\Debug
,stdafx.h
和targetver.h
。
回答by LihO
Possible solution 1:
可能的解决方案1:
#include "../myProject.h"
Possible solution 2:
可能的解决方案2:
Project Properties ~> C/C++ ~> General ~> Additional Include Directories, try to set there path relative to the directory where is your .sln
(solution) file. If the solution is in U:\Software Development\c++ projects\myProject\
then try to set it to $(SolutionDir)myProject
Project Properties ~> C/C++ ~> General ~> Additional Include Directories,尝试设置相对于.sln
(解决方案)文件所在目录的路径。如果解决方案在,U:\Software Development\c++ projects\myProject\
然后尝试将其设置为$(SolutionDir)myProject