Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR: Cannot open source file " "

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

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.

like image 818
Nick Avatar asked Mar 17 '12 21:03

Nick


People also ask

How do I run a code in Visual Studio C++?

Build and run your code in Visual Studio To build your project, choose Build Solution from the Build menu. The Output window shows the results of the build process. To run the code, on the menu bar, choose Debug, Start without debugging. A console window opens and then runs your app.


2 Answers

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" 

This is if you have a structure like this:

Root\ProjectA

Root\ProjectB <- GameEngine.h actually lives here

like image 117
EdChum Avatar answered Sep 24 '22 07:09

EdChum


Just in case there is someone out there who's a bit new like me, double check that you are spelling your header folders correctly.

For example:

<#include "Component/BoxComponent.h" 

This will result in the error. Instead, it needs to be:

<#include "Components/BoxComponent.h" 
like image 28
Megan Frazier Avatar answered Sep 20 '22 07:09

Megan Frazier