原文链接:http://www.juzicode.com/archives/3729
错误提示:
编译时在包含头文件处提示: 无法打开包括文件: “def.hpp”: No such file or directory juzicodedemo E:\juzicode\com\a\src\main.cpp 2
#include <iostream>
#include "def.hpp"
using namespace std;
int main(void)
{
TS_DATA td;
cout << "juzicode.com" << endl;
cout << "vx:桔子code" << endl;
return 0;
}

在这个例子中def.hpp在include目录下,工程文件在juzicodedemo目录下:

错误原因:
1、提示没有找到相应的头文件“def.hpp”,VS在默认的路径下没有找到def.hpp文件,所以提示出错。
解决方法:
1、当前工程的工作目录在 juzicodedemo 路径下,def.hpp所在的路径相对当前工作路径就是“..\include”:

找到项目的属性页, 在工程属性–配置属性–VC++目录–包含目录中添加相对路径“..\include”:

如果本文还没有完全解决你的疑惑,你也可以在微信公众号“桔子code”后台给我留言,欢迎一起探讨交流。
