# "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 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?

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

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627686
• Total Posts
2978635

• 11
• 14
• 12
• 10
• 12