I am using visual studio 2005 to create a project. And I have folder structure in project as: a folder called code. this folder contains all *.cxx files.
Now, I have created a class xyz in header file xyz.h. And defined every thing in xyz.cxx which is placed in code folder. But now when I try to compile it with visual studio it throws me an error "fatal error C1083: Cannot open include file: 'xyz.h': No such file or directory". how to rectify this problem.
Add the "code" folder to the project properties within Visual Studio
Project->Properties->Configuration Properties->C/C++->Additional Include Directories
Either move the xyz.h file somewhere else so the preprocessor can find it, or else change the #include
statement so the preprocessor finds it where it already is.
Where the preprocessor looks for included files is described here. One solution is to put the xyz.h file in a folder where the preprocessor is going to find it while following that search pattern.
Alternatively you can change the #include statement so that the preprocessor can find it. You tell us the xyz.cxx file is is in the 'code' folder but you don't tell us where you've put the xyz.h file. Let's say your file structure looks like this...
<some folder>\xyz.h
<some folder>\code\xyz.cxx
In that case the #include statement in xyz.cxx should look something like this..
#include "..\xyz.h"
On the other hand let's say your file structure looks like this...
<some folder>\include\xyz.h
<some folder>\code\xyz.cxx
In that case the #include statement in xyz.cxx should look something like this..
#include "..\include\xyz.h"
Update: On the other other hand as @In silico points out in the comments, if you are using #include <xyz.h>
you should probably change it to #include "xyz.h"
I ran into this error in a different situation, posting the resolution for those arriving via search: from within Visual Studio, I had copied a file from one project and pasted into another. Turns out that creates a symbolic link, not an actual copy. Thus the project did not find the file in the current working directory as expected. When I made a physical copy instead, in Windows Explorer, suddenly #include "myfile.h"
worked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With