1.11M Members

fatal error C1083: Cannot open include file: 'test.h': No such file or director

 
0
 

I am getting this error even though a) the header file does exist and is located in the directory and it's not somehow been switched to read only. Also, my #include statement uses "" like "test.h" so the compiler knows to look in the project directory first.

I've read that perhaps it has to do with the pch stdafx.h or stdafx.cpp and I've looked in project settings and it is set to use precompiled header through stdafx.h.

So what should I look into/try next?

Is the problem that the #include "test.h" gets called before the pch stdafx.h?

Thanks, I'm adapting code from a larger project and I'm clueless on this one.

 
1
 

Since you are using precompiled headers, stdafx.h must be the first include file in stdafx.cpp and all other *.cpp files of the project. Other *.h files can be included after stdafx.h and will not be included in the *.pch precompiled header file.

I don't think that is the problem though because the compiler would have given a different error message. So the only other possibility is that test.h is not located in the directory you think it is. It should be in the same folder as the other project .cpp files.

 
0
 

Just wanted to post a follow up. Thank you ancient dragon. You were correct. The compiler was unable to find the test.h header because it was located in a subdirectory of the project directory. I thought this would be remedied by adding the header file to the project, but it was still unable to find it. The solution to the problem was to replace

#include "test.h"

with

#include "..\subdirectory\test.h"
Question Answered as of 3 Years Ago by Ancient Dragon
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article