错误:无法打开源文件" [英] ERROR: Cannot open source file " "

查看:24
本文介绍了错误:无法打开源文件"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行 Visual Studio C++ 并且我有一个头文件GameEngine.h",我试图让另一个文件看到.

I am running visual studio C++ and I have a header file "GameEngine.h" that I am trying to have another file see.

当我 #include "GameEngine.h" 时,它给了我无法打开源文件的错误.我不知道该怎么做.我实际上已经这样做了一千次,但由于某种原因,这现在不起作用.

When I #include "GameEngine.h" it gives me the error that it cannot open the source file. I have no idea what to do. I have done this literally a thousand times but for some reason this is now not working.

推荐答案

你需要检查你的项目设置,在C++下,检查include目录并确保它指向对于 GameEngine.h 所在的位置,另一个问题可能是 GameEngine.h 不在您的源文件夹或任何包含目录中,而是位于相对于你的项目文件夹.例如,您有 2 个项目 ProjectAProjectB,如果您在 ProjectA<的某个源/头文件中包含 GameEngine.h/code> 然后正确包含它,假设 ProjectB 在同一个父文件夹中,请执行以下操作:

You need to check your project settings, under C++, check include directories and make sure it points to where GameEngine.h resides, the other issue could be that GameEngine.h is not in your source file folder or in any include directory and resides in a different folder relative to your project folder. For instance you have 2 projects ProjectA and ProjectB, if you are including GameEngine.h in some source/header file in ProjectA then to include it properly, assuming that ProjectB is in the same parent folder do this:

include "../ProjectB/GameEngine.h"

如果你有这样的结构:

RootProjectA

RootProjectA

RootProjectB <- GameEngine.h 实际上就在这里

RootProjectB <- GameEngine.h actually lives here

这篇关于错误:无法打开源文件&quot;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆