While running all codes in visual c++ it gives me the same error -"Error 1 fatal error C1083: Cannot open include file: 'test.h': No such file or directory c:\users\ila\documents\visual studio 2008\projects\game\game\testgame.cpp 1
"
I have created the header file test.h.

Dani AI

Generated

The compiler error C1083 means the compiler cannot locate the header file at compile time. is right that starting a fresh project can quickly rule out broken project settings, and is correct that the file might be missing or misnamed on disk. The following checklist covers the common, often-missed causes and fixes.

  • Confirm the physical file and exact filename (no hidden ".txt" extension or extra spaces). In Solution Explorer right‑click the header -> Properties -> Full Path, or "Open Containing Folder".
  • Verify the include line and use quotes for local headers, for example #include "test.h". If the header lives in a subfolder use a relative path ("inc/test.h").
  • Ensure the compiler searches the folder: Project Properties -> Configuration (check Debug/Release and platform) -> C/C++ -> General -> Additional Include Directories. Use macros like $(ProjectDir)\Include if helpful.
  • Remember Solution Explorer filters are virtual; a header shown under "Header Files" may actually sit in a different disk folder.
  • Clean/Rebuild the solution and restart Visual Studio to clear stale state. Use Add Existing Item to place the header into the project if needed.
  • On non-Windows or case-sensitive checkouts (WSL, some Git setups) confirm filename case matches the include.

If the header is still not found, compare the compiler's include search list (Project Properties -> C/C++ -> Command Line shows the invoked command) to the header location to find the mismatch.

Recommended Answers

All 2 Replies

Try starting a new project and copying and pasting the code from the existing one into the new one.

Is test.h still in your source directory? That error could also be telling you the file is missing or corrupted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.