Barney Chambers
Barney Chambers

Reputation: 2783

Why can't C++ find GLM headers?

I do not have permissions to put GLM into usr/local/include or usr/include but I need to use GLM for openGL. The code (I am not able to change) looks for GLM like this:

#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>

the folder glm is in the same directory as my main.cpp where this code is from. I think it's not working because it's looking for glm in usr/include where in built headers are (im using redhat linux)

How can I stop this from happening, since I cannot run:

 g++ main.cpp -lGL -lglut -lGLEW

without these errors:

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

Upvotes: 22

Views: 56092

Answers (3)

PrimalMachine
PrimalMachine

Reputation: 1

im using CLion and had the same issue. when i did <PATH_TO_GLM_FROM_CONTENT_ROOT> it didnt work, however whe i did "PATH_TO_GLM_FROM_CONTENT_ROOT" it did work.for some reason having the path between "<>" was causing it. also when i did <ABSOLUTE_PATH_TO_GLM> it did work.

EXAMPLE OF WORKING CODE: #include "glm\glm.hpp" #include "glm\gtc\matrix_transform.hpp" #include "glm\gtc\type_ptr.hpp"

Upvotes: 0

Jherico
Jherico

Reputation: 29240

GLM is not part of OpenGL. It's a C++ math library that has much of the same syntax as GLSL. In order to use it you need to download it from here or install it using your package manager (although if you don't have administrative rights on this machine, then you won't be able to do that).

Once you have it, you need to add it to your include path:

g++ main.cpp -lGL -lglut -lGLEW -I/path/to/glm/headers

Although if you install it with a package manager it will probably end up in your system include path.

Upvotes: 19

Sergey Tselovalnikov
Sergey Tselovalnikov

Reputation: 6036

My answer isn't really related to the author's question, but I'm just leaving it here for those, who come here from ubuntu with a missing package

sudo apt-get install libglm-dev

Upvotes: 63

Related Questions