Documentation/tutorial on using gl4es with GLU on Emscripten
Maybe there's some basic C/C++ I don't understand, but I'm having some difficulty using GLU with gl4es on Emscripten. Tried a bunch of things, and I keep getting linker errors. Sometimes stuff like error: undefined symbol: mgluScaleImage (referenced by top-level compiled C/C++ code), sometimes stuff like glEnd being missing.
A tutorial or documentation on using these together would be a nice thing to have, in my opinion.
I do note that gl4es defines USE_MGL_NAMESPACE for Emscripten and Apple, and GLU only does so for Apple. The only way I could think of to fix that is to tamper with the header in GLU.
I have never tried GLU in an emscriptem project. Some mangling may be needed indded, I'm unsure as I have not do it myself.
But glEnd(...) should never be missing, as it's part of libGL, so including libGL.a generated for emscriptem should resolve that issue.
What I'm trying for now is copying the gl4es headers to GLU, and commenting out #include "glu_mangle.h", so that the GLU exports non-prefixed names, while using gl4es's mangled names.
Is that a coherent thing to do? Probably not the cleanest. And I still don't have my project running (more linking errors unrelated to these), so I can't tell if it works properly.
Yeah, that could work. GL needs to be mangled in Emscripten, but not GLU.
Hi @Sgeo @ptitSeb Could you maybe explain a bit more in detail what you did to get GLU running when compiling with Emscripten? Glu is shipped with Emscripten, so i don't think that i need to recompile it myself right?
If i am not changing anything inside the source code of gl4es i get the following error:
[build] wasm-ld: error: ...example.a(example.cpp.o): undefined symbol: mgluUnProject
I've tried to comment out #include "glu_mangle.h" inside glu.h but this time i get a different result:
[build] wasm-ld: error: ...example.a(example.cpp.o): undefined symbol: gluUnProject
So it seems like i am missing an exported version of the unmangled names right? What do you mean when you say "I'm trying for now is copying the gl4es headers to GLU". Did you copy glu.h to the Emscripten GLU include folder?
Okay seems like i fixed it myself. It was necessary to compile GLU because Emscripten doesn't ship a this library (only the header files). Here is the CMakeLists.txt that i used (as there is none in the repository :
include_directories(util)
file(GLOB_RECURSE GLU_SOURCES
*.h
*.c)
add_library(GLU STATIC ${GLU_SOURCES})
include_directories(src/include)
target_compile_options(GLU
PRIVATE
-O0
)
add_library(mw::gl4es_glu ALIAS GLU)
After that it is possible to link against GLU and use it's functions as soon as you disable line 35 in glu.h from gl4es, so this repo:
(// #include "glu_mangle.h").