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

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
 
A

Anna Smidt

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
 
D

David Lowndes

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
 
D

David Wilkinson

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>
 
D

David Wilkinson

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.
 
A

Anna Smidt

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
 
D

David Wilkinson

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?
 
P

Pavel A.

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
 
A

Anna Smidt

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top