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

后端 未结 4 1528
遥遥无期
遥遥无期 2020-12-06 09:52

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 hav

相关标签:
4条回答
  • 2020-12-06 10:19

    The following approach helped me.

    Steps :

    1.Go to the corresponding directory where the header file that is missing is located. (In my case,../include/unicode/coll.h was missing) and copy the directory location where the header file is located.(Copy till the include directory.)

    2.Right click on your project in the Solution Explorer->Properties->Configuration Properties->VC++ Directories->Include Directories. Paste the copied path here.

    3.This solved my problem.I hope this helps !

    0 讨论(0)
  • 2020-12-06 10:31

    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"

    0 讨论(0)
  • 2020-12-06 10:32

    Add the "code" folder to the project properties within Visual Studio

    Project->Properties->Configuration Properties->C/C++->Additional Include Directories

    0 讨论(0)
  • 2020-12-06 10:39

    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.

    0 讨论(0)
提交回复
热议问题