Included file not found, but I don't know why

  • Thread starter Thread starter Anna Smidt
  • Start date Start date
A

Anna Smidt

I have declared an include file:

// gsl.config must be included for correct build with inline correctly
defined etc.
#include "gsl/config.h"

And the compiler says:
Error 4 fatal error C1083: Cannot open include file: 'gsl/config.h': No
such file or directory

But it's in the subfolder c:\MYPROJECT\gsl\gsl\config.h

Additionally I have set this directory to be included by going to the
VC++ Project settings and defining the path
C:\MYPROJECT\gsl\
and
C:\MYPROJECT\gsl\gsl

Can somebody tell me how he would go on now?

Thanks again.
Anna
 
It only works when I specify full paths... something like that:

#include "C:\MyProject\gsl\gsl\config.h"

But not if I do it like this:
#include "gsl/config.h"

I don't know what I did wrong.

Anna
 
It only works when I specify full paths... something like that:
#include "C:\MyProject\gsl\gsl\config.h"

But not if I do it like this:
#include "gsl/config.h"

I don't know what I did wrong.

Perhaps the relative path isn't quite right - does it need ..\
prepending perhaps?

Dave
 
Anna said:
I have declared an include file:

// gsl.config must be included for correct build with inline correctly
defined etc.
#include "gsl/config.h"

And the compiler says:
Error 4 fatal error C1083: Cannot open include file:
'gsl/config.h': No such file or directory

But it's in the subfolder c:\MYPROJECT\gsl\gsl\config.h

Additionally I have set this directory to be included by going to the
VC++ Project settings and defining the path
C:\MYPROJECT\gsl\
and
C:\MYPROJECT\gsl\gsl

Anna:

Where is the file that contains the statement

#include "gsl/config.h"

If config.h is in

c:\MYPROJECT\gsl\gsl

then the originating file should be in

c:\MYPROJECT\gsl

When you define additional directories you would need to specify

C:\MYPROJECT\gsl

Note that the trailing backslash is not needed here, and could be the cause of
the problem.

Note also that if you add this directory (either in the project or the VC
settings) then you can (I would say should) use the angle bracket form

#include <gsl/config.h>
 
Anna said:
What do you mean by "originating file", please? Do you mean "config.h"
or do you mean the file where #include <gsl/config.h> is written?

Yes, I mean the file where the #include statement is written. Wasn't this
obvious from the part of my post that you did not quote?

Also, if config.h is in c:\MYPROJECT\gsl\gsl then it is not in c:\MYPROJECT\gsl,
so that could not have been my meaning.
 
I have managed to make it, but I don't understand why it works.
At first I had these additional include directories:

\PROGRA~1\OpenCV\cv\include;\PROGRA~1\OpenCV\cxcore\include;\PROGRA~1\OpenCV\otherlibs\highgui;..\regex;..\gsl;..\gsl\gsl;..\image;..\jpeg;..\mat;..\rowley;..\stasm;..\tasm;

Then I added the explicit path (see end of line), and it worked:

\PROGRA~1\OpenCV\cv\include;\PROGRA~1\OpenCV\cxcore\include;\PROGRA~1\OpenCV\otherlibs\highgui;..\regex;..\gsl;..\gsl\gsl;..\image;..\jpeg;..\mat;..\rowley;..\stasm;..\tasm;"C:\MyProject\gsl";"C:\MyProject\gsl\gsl"

It is unclear to me why

...\gsl;..\gsl\gsl;..

doesn't did resolve to

"C:\MyProject\gsl\gsl"
"C:\MyProject\gsl"

Anna
 
Anna said:
I have managed to make it, but I don't understand why it works.
At first I had these additional include directories:

\PROGRA~1\OpenCV\cv\include;\PROGRA~1\OpenCV\cxcore\include;\PROGRA~1\OpenCV\otherlibs\highgui;..\regex;..\gsl;..\gsl\gsl;..\image;..\jpeg;..\mat;..\rowley;..\stasm;..\tasm;


Then I added the explicit path (see end of line), and it worked:

\PROGRA~1\OpenCV\cv\include;\PROGRA~1\OpenCV\cxcore\include;\PROGRA~1\OpenCV\otherlibs\highgui;..\regex;..\gsl;..\gsl\gsl;..\image;..\jpeg;..\mat;..\rowley;..\stasm;..\tasm;"C:\MyProject\gsl";"C:\MyProject\gsl\gsl"


It is unclear to me why

..\gsl;..\gsl\gsl;..

doesn't did resolve to

"C:\MyProject\gsl\gsl"
"C:\MyProject\gsl"

Anna:

When you add additional directories to the project, relative paths are relative
to the project file (.vcproj). If this file is in C:\MyProject then ..\gsl is
C:\gsl (which does not exist).

What happens if you just add "gsl" to the directory list?
 
Relative paths in includes, etc. are relative to the directory of the
..vcproj file.
Maybe your .vcproj is located not in same directory with the .cpp files

--PA
 
So true!
I don't know what I was thinking when I typed "..\gsl". It was like "go
outside of the pizza shop and order your pizza from there" which isn't
very intelligent.
I think I was very exhausted.
Thanks.
Anna
 
Back
Top