0

I'm trying to compile a project, but SCons can't find glm/glm.hpp... This is my SConstruct:

VariantDir('build', '.')
env=Environment(CPPPATH=['.'], CPPDEFINES=[], LIBS=[], CXXFLAGS="-std=c++0x")
env.Program(target='exec_test', source=[Glob('build/*.cpp'), Glob('build/*.hpp')])

and this is the output:

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: building associated VariantDir targets: build
g++ -o build/game.o -c -std=c++0x -I. build/game.cpp
g++ -o build/main.o -c -std=c++0x -I. build/main.cpp
g++ -o exec_test build/game.o build/main.o build/game.hpp
build/game.hpp:15:23: fatal error: glm/glm.hpp: No such file or directory
 #include <glm/glm.hpp>
                       ^
compilation terminated.
scons: *** [exec_test] Error 1
scons: building terminated because of errors.

main.cpp , game.cpp and game.hpp are in current directory, and glm.hpp is in glm/glm.hpp (from the current directory)

What am i doing wrong?

Edit:

I've done some editing, and i realized a very strange thing: I get the error only in game.hpp! I also tried to remove the glm include line, and i got a warning that some code is only available in c++11. That means that none of scons building arguments are used for game.hpp. I also tried including glm in main.cpp and game.cpp and it compiled without errors or warnings. I think that not about the game.hpp file, it's about scons not building .hpp files with the arguments in the SConstruct.

Qualphey
  • 1,244
  • 1
  • 19
  • 44
  • because they are copied to the build directory when compiling – Qualphey Oct 19 '13 at 16:54
  • Try it first without the call to VariantDir, to rule out any include path problems introduced by the variant dir. – Brady Oct 19 '13 at 17:24
  • 1
    An observation that is probably the cause of your latest problem with game.hpp: You shouldnt be listing header files as source files in the call to Program() since you dont typically compile headers. – Brady Oct 20 '13 at 12:06
  • If you're still having problems with the include paths, you should try to isolate if its due to the VariantDir, or due to the fact that you're using '.' as the include path instead of perhaps '#' which SCons interprets as relative to the root dir. – Brady Oct 20 '13 at 13:04
  • after removing headers from the source list, i'm not facing any problems with the the header inclusion. You can write that as an anwser and i will accept it! :) – Qualphey Oct 20 '13 at 16:28

1 Answers1

1

You should not be including header files in the source list when compiling. Consider changing your call to Program() as follows:

env.Program(target='exec_test', source=[Glob('build/*.cpp')])
Brady
  • 10,207
  • 2
  • 20
  • 59