Sign in to follow this  
hburd

"No such file or directory" but it's obviously there!

Recommended Posts

I'm trying to include my vector class

#include "math/Vec2.h"

and Vec2.h is obviously in the math directory.

 

I have no idea how this is happening, but when I try to compile I get "math/Vec2.h: no such file or directory"

 

I have another file in the math directory called "Mat3x3.h" which I can include just fine:

#include "math/Mat3x3.h"    //no problem

What could I possibly be doing wrong? Obviously I've double checked the filename for any typos.

Share this post


Link to post
Share on other sites

OS is linux, compiler is g++. But I just tried adding -I . to the compile command and now the problem's gone.

 

Now the real question is, why was #include "math/Mat3x3.h" working before I did this? But moreover, why do I even have to add -I . to the compile command? Isn't the current directory searched in by default when using quotations instead of angle brackets?

Share this post


Link to post
Share on other sites

Are you trying to include Vec2.h and Mat3x3.h from the same .c or .cpp file? Or is it one file using Vec2.h and another file using Mat3x3.h?

 

They're included in a couple of files, all of which include both.

 

Edit: with the exception of Mat3x3, which only includes Vec2.

Edited by hburd

Share this post


Link to post
Share on other sites


They're included in a couple of files, all of which include both.

Edit: with the exception of Mat3x3, which only includes Vec2.

Don't forget that the paths are relative to the file being included, not the current working directory of the build process, so be sure to double-check your paths; if the path is specified wrong, it may attempt to check the path relative to the paths in your include path environment variables or commandline switches. This would cause it to work with the -I switch, but not otherwise, if this is the problem.

Share this post


Link to post
Share on other sites

Yeah, I guess that would have been the problem. So the error would have been coming from the Mat3x3 I included instead of the Vec2. I didn't think of that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this