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

Started by
5 comments, last by hburd 9 years, 8 months ago

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.

Advertisement

These things are so common, you'd think all these issues would be worked out. But we need a little more info:

OS

Compiler/IDE

Off the top of my head, either you think that the math/Vec2.h file has been added to the include path but it has not, or you've moved from windows where file names are case insensitive to Linux where case matters.

If it makes you feel any better, I've been coding since the 90s and I just spent two days trying to get my windows C++ compiler to link some SFML static libraries. That actually doesn't make me feel any better.

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

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?

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

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?

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.


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.

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.

This topic is closed to new replies.

Advertisement