0

我正在尝试编译一个项目,但 SCons 找不到 glm/glm.hpp... 这是我的 SConstruct:

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

这是输出:

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 和 game.hpp 在当前目录下, glm.hpp 在 glm/glm.hpp (从当前目录下)

我究竟做错了什么?

编辑:

我做了一些编辑,我意识到一件很奇怪的事情:我只在game.hpp中得到错误!我还尝试删除 glm 包含行,并且收到警告说某些代码仅在 c++11 中可用。这意味着没有 scons 构建参数用于 game.hpp。我还尝试在 main.cpp 和 game.cpp 中包含 glm,它编译时没有错误或警告。我认为这不是关于 game.hpp 文件,而是关于 scons 没有使用 SConstruct 中的参数构建 .hpp 文件。

4

1 回答 1

1

编译时不应在源列表中包含头文件。考虑将您的调用更改Program()为如下:

env.Program(target='exec_test', source=[Glob('build/*.cpp')])
于 2013-10-21T05:53:52.773 回答