为什么C++找不到 GLM 标头?
Why can't C++ find GLM headers?
我没有权限将 GLM 放入 usr/local/include 或 usr/include 中,但我需要使用 GLM 进行 openGL。代码(我无法更改)像这样查找 GLM:
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
文件夹 glm 与我的主目录位于同一目录中.cpp此代码来自该目录。我认为它不起作用,因为它正在 usr/include 中寻找 glm 内置标头中的位置(我使用 redhat linux)
我怎么能阻止这种情况发生,因为我无法运行:
g++ main.cpp -lGL -lglut -lGLEW
没有这些错误:
main.cpp:46:23: error: glm/glm.hpp: No such file or directory
main.cpp:47:40: error: glm/gtc/matrix_transform.hpp: No such file or directory
main.cpp:48:32: error: glm/gtc/type_ptr.hpp: No such file or directory
main.cpp:62: error: ‘glm’ has not been declared
main.cpp:62: error: expected constructor, destructor, or type conversion before ‘cameraMatrix’
main.cpp: In function ‘int setShaderData(const unsigned int&)’:
main.cpp:102: error: ‘glm’ has not been declared
main.cpp:102: error: expected ‘;’ before ‘projection’
main.cpp:105: error: ‘glm’ has not been declared
main.cpp:105: error: ‘projection’ was not declared in this scope
main.cpp:109: error: ‘glm’ has not been declared
main.cpp:109: error: expected ‘;’ before ‘modelview’
main.cpp: In function ‘void render()’:
main.cpp:187: error: ‘cameraMatrix’ was not declared in this scope
main.cpp:187: error: ‘glm’ has not been declared
main.cpp:200: error: ‘glm’ has not been declared
我的回答与作者的问题并没有真正的关系,但我只是把它留给那些从 ubuntu 来到这里的人,他们缺少一个包
sudo apt-get install libglm-dev
GLM 不是 OpenGL 的一部分。这是一个C++数学库,具有与 GLSL 大致相同的语法。为了使用它,您需要从此处下载它或使用包管理器安装它(尽管如果您在这台计算机上没有管理权限,那么您将无法执行此操作)。
拥有它后,您需要将其添加到包含路径中:
g++ main.cpp -lGL -lglut -lGLEW -I/path/to/glm/headers
尽管如果您使用包管理器安装它,它可能会最终出现在您的系统包含路径中。
相关文章:
- g++ 说函数不存在,即使包含正确的标头
- spdlog标头仅与外部fmt一起使用.spdlog错误:'内部':不是'fmt'
- 在CMake中使用find_package时,是否会显式包含标头
- 错误"Could not find Boost"(缺少:上下文标头)
- 如何在标头中声明(或定义)函数的问题
- 如何避免在仅标头库中C++类/变量重定义
- C++算法标头中,为什么要使用 "!(val < *first)" ?
- C++标头错误 C2238 意外标记";"
- std::initializer_list,大括号初始化和标头
- 在 c++ 中拆分类和标头中的继承,错误
- 如何确定哪个标头调用 c++ 中的另一个标头
- 如何在生成文件中添加多个标头 (HDR) 和对象?
- 我可以在运行时重新定义在 OpenCascade/OCCT 标头中定义的 c++ 静态常量吗?
- GCC,CMake,预编译标头和维护依赖项
- VisualStudio:使用 Suse Enterprise Server 12 SP5 时,不会下载远程库标头
- 一个标头库中的错误
- 可视化 Bazel C++预编译标头实现
- 如何告诉CMAKE下载一些必要的标头文件(更精确的GLM数学库),而无需编译它们
- 为什么C++找不到 GLM 标头?
- 仅标头C++库 (GLM) 无法使用 Android-NDK 进行编译