我正在尝试编译一个项目,但是 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 include 行,但我收到一条警告,指出某些代码仅在 c++11 中可用。这意味着没有任何 scons 构建参数用于 game.hpp。我还尝试在 main.cpp 和 game.cpp 中包含 glm,并且编译时没有错误或警告。我认为这与 game.hpp 文件无关,而是关于 scons 而不是使用 SConstruct 中的参数构建 .hpp 文件。
最佳答案
编译时不应在源列表中包含头文件。考虑如下更改对 Program()
的调用:
env.Program(target='exec_test', source=[Glob('build/*.cpp')])
关于c++ - 使用 SCons 编译时找不到 glm.hpp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19468034/