C++ – C1083: Cannot open include file: … : No such file or directory

cvisual studio 2010

I have a strange error C1083 (cannot the header file). I've read other C1083 post, but I think my is different:

1) The header file is added in my project properties under the additional includes property.

2) Another class uses the same header (Same project), and it compiles. The problem doesn't occur until I added my header file to the second header file.

3) I use the auto complete/intellesense to make a "..\include\myClass.h" file. One suggestion was the I was using the wrong path, but everything was in the same directory. I tried it anyways.

All the files are in the same directory and that directory is included in the additional includes property.

In essence part of the project sees it but the other part doesn't? I don't know what I am missing.

Best Answer

If the target "include" directory is added to "additiona includes" project property, then you really don't need the path at all.

I mean, having:

\myFolder\project
                 \project.vcproj
                 \source
                      \myCode.cpp    <- compiling this one here?
                 \data
                      \myDb.foo
                 \include            <- this DIR#1
                         \foo1.h
                         \myClass.h  <- this FILE#1
                         \foo2.h
                         \lib1
                              \bar.h <- this FILE#2

if you added DIR#1 to "additional include directories", then:

#include "myClass.h"  // to include FILE#1
#include "lib1\bar.h"  // to include FILE#2

should be enough.

In case you not added the path there, the following should work:

#include "include\myClass.h"  // to include FILE#1
#include "include\lib1\bar.h"  // to include FILE#2

If you added the path and the first does not work, but the second one works, then you added the path incorrectly - make absolutely sure that the file/folder structure is really the same as you think it is. Also, if you added relative path to the project, try changing it to absolute.