c++ - 使用 SCons 编译时找不到 glm.hpp

标签 c++ scons

我正在尝试编译一个项目,但是 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/

相关文章:

c++ - 函数返回指向自身的指针?

c++ - 在 .cpp 或 .h 文件中,我应该在哪里包含头文件?

c++ - 在centos上构建gcc?

c++ - 如果数据类型为整数或 double 值,则 c++ 返回 true/false

scons - 从 external.py 文件读取 scons 构建变量

c++ - 从模板化类中的模板化类的属性继承

performance - Environment.Clone 窃取启动时间

java - 在 Windows 上为 android 构建 iotivity 时出错

linux - 在 Linux 上安装 Mongodb C++ 驱动程序

python - 运行scons的问题