We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,489 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

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

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.

2
Contributors
2
Replies
3 Days
Discussion Span
2 Years Ago
Last Updated
4
Views
Question
Answered
Jsplinter
Junior Poster in Training
77 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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.

Ancient Dragon
Achieved Level 70
Team Colleague
32,161 posts since Aug 2005
Reputation Points: 5,836
Solved Threads: 2,577
Skill Endorsements: 69

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"
Jsplinter
Junior Poster in Training
77 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 2 Years Ago by Ancient Dragon

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0764 seconds using 2.67MB