8

此问题相关,我在用于测试 DLL 的控制台应用程序的代码中包含了一个头文件,但 Visual Studio 返回以下错误:

error C1083: Cannot open include file: 'myProject.h': No such file or directory

但是我已经myProject.h在 Additional Include Directories 中包含了文件夹路径。我还尝试在 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);
}

当我键入“#include”时,Intellisense 只显示 3 个项目:对应于U:\Software Development\c++ projects\myProject\myProject\Debugstdafx.h和的 Debug 文件夹targetver.h

4

1 回答 1

7

可能的解决方案1:

#include "../myProject.h"

可能的解决方案2:

Project Properties ~> C/C++ ~> General ~> Additional Include Directories,尝试设置相对于您的.sln(解决方案)文件所在目录的路径。如果解决方案在,U:\Software Development\c++ projects\myProject\则尝试将其设置为$(SolutionDir)myProject

于 2013-10-12T00:32:28.680 回答