Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Visual Studios : can not open include file ... eh?

Sorry for posting such a lowly beginner's question, but I just still don't know my way around Visual Studios yet. I'm trying to compile a code in C++ Visual Studios:

#include "Banana.h"

int main(int argc, char* argv[])
{
    fruit::Banana banana;
    banana.dance();
    return 0;
}

and I'm getting an error

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

But in the Solution Explorer under the project that I'm working with there is a source folder labeled "fruit/Header Files" and within that folder is "Banana.h". I thought that everything in the source folders within the same project were automatically on the source path. What gives?

like image 293
JnBrymn Avatar asked Jul 30 '10 21:07

JnBrymn


People also ask

How do I add the include path in Visual Studio?

Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio. Select the Configuration Properties > C/C++ > General property page. Modify the Additional Include Directories property.

How do I fix error C1083?

When the header file is not found, the compiler generates a C1083 error. The fix for this problem is to use the correct file, not to add the header file or directory to the build.

How do you fix No such file or directory in VS code?

Try reinstalling mingw. Basically, the problem is with header files. I think you should try reinstalling mingw, adding it to system path again or try installing the extension in vscode.

What is Stdafx H?

The file stdafx. h is usually used as a precompiled header file. Precompiled headers help to speed up compilation when a group of files in a project do not change.


1 Answers

You will need to configure additional include paths. If you go to the Project Properties, you'll find it under Configuration Properties, C/C++ at the top.

like image 132
Mark Ransom Avatar answered Sep 30 '22 16:09

Mark Ransom