Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emscripten with GLM

Ball.h:7:10: fatal error:
  'glm/glm.hpp' file not found
#include <glm/glm.hpp>
     ^
1 warning and 1 error generated.
ERROR:root:compiler frontend failed to generate LLVM bitcode, halting

I have tried to compile my C++ project with Emscripten. However I get the error above. It runs fine in VS15. How can I fix this?

I can do this and it will compile:

#include "..\..\packages\glm.0.9.6.3\build\native\include\glm\glm.hpp"

or create one header file eg.

myglm.h

where I will include this and other source files will include myglm.h,

however I wonder if is there a better way?

Thank you

like image 721
rluks Avatar asked May 31 '26 18:05

rluks


1 Answers

I found a solution thanks to CoffeeDeveloper's comments on this question : Using libraries with emscripten

glm can be compiled with Emscripten because is platform independent (literally add glm source code to your source tree, and provided you have correct path to includes and you defined correct GLM configuration macros that should compile).

#define GLM_FORCE_PURE before including GLM in every place you use it. Hopefully create a new header file #define GLM_FORCE_PURE (newline) #include <glm/glm.hpp>.. It should work out-of-the-box. Use a new header so that you don't have to remember to define GLM_FORCE_PURE everytime you include it

It worked perfectly for me, just add glm source code files to your project and include them like this :

#define GLM_FORCE_PURE
#include <glm/glm.hpp>
like image 66
Aracthor Avatar answered Jun 02 '26 18:06

Aracthor