Using Emscripten, I've been trying to compile the ImpulseEngine project by Randy Gaul (C++) to a JavaScript program. Once I got Emscripten running, I followed the tutorial described here. I followed all of the steps: Linking the .cpp files into the .bc files, then compiling those into a .js.
Here's a list of the commands I ran:
.cpp -> .bc:
emcc ImpulseEngine-master/main.cpp -o main.bc
emcc ImpulseEngine-master/Scene.cpp -o Scene.bc
emcc ImpulseEngine-master/Render.cpp -o Render.bc
emcc ImpulseEngine-master/Precompiled.cpp -o Precompiled.bc
emcc ImpulseEngine-master/Manifold.cpp -o Manifold.bc
emcc ImpulseEngine-master/Collision.cpp -o Collision.bc
emcc ImpulseEngine-master/Clock.cpp -o Clock.bc
emcc ImpulseEngine-master/Body.cpp -o Body.bc
.bc -> .js
emcc main.bc Scene.bc Render.bc Precompiled.bc Manifold.bc Collision.bc Clock.bc Body.bc -s LEGACY_GL_EMULATION=1 -o github/khanfusiion3.github.io/index.html
Note the -s LEGACY_GL_EMULATION=1
option: That's for enabling the OpenGL features. Granted, when I ran the command, I still received a few warnings about unresolved symbols, as seen here:
warning: unresolved symbol: glPointSize
warning: unresolved symbol: glRasterPos2i
warning: unresolved symbol: glutBitmapCharacter
warning: unresolved symbol: glutBitmap9By15
Theoretically, the program will fail now regardless of what happens next, but I tried anyways. It immediately threw an error and exited. Here is a list of every error logged to the console:
WARNING: using emscripten GL emulation. This is a collection of limited workarounds, do not expect it to work.Module.printErr @ khanfusiion3.github.io/:1249
khanfusiion3.github.io/:1249 WARNING: using emscripten GL emulation unsafe opts. If weirdness happens, try -s GL_UNSAFE_OPTS=0Module.printErr @ khanfusiion3.github.io/:1249
khanfusiion3.github.io/:1249 pre-main prep time: 12 msModule.printErr @ khanfusiion3.github.io/:1249
khanfusiion3.github.io/:1249 WARNING: using emscripten GL immediate mode emulation. This is very limited in what it supportsModule.printErr @ khanfusiion3.github.io/:1249
khanfusiion3.github.io/:1249 missing function: glRasterPos2iModule.printErr @ khanfusiion3.github.io/:1249
khanfusiion3.github.io/:1237 -1
khanfusiion3.github.io/:1249 -1Module.printErr @ khanfusiion3.github.io/:1249
khanfusiion3.github.io/:1249 warning: build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demanglingModule.printErr @ khanfusiion3.github.io/:1249
/index.js:1879 Uncaught abort(-1) at Error
at jsStackTrace (http://khanfusiion3.github.io/index.js:1060:13)
at stackTrace (http://khanfusiion3.github.io/index.js:1077:22)
at abort (http://khanfusiion3.github.io/index.js:25065:44)
at _glRasterPos2i (http://khanfusiion3.github.io/index.js:8051:58)
at __Z12RenderStringiiPKc (http://khanfusiion3.github.io/index.js:13374:2)
at Array.__Z11PhysicsLoopv (http://khanfusiion3.github.io/index.js:9462:2)
at dynCall_v (http://khanfusiion3.github.io/index.js:24605:30)
at Object.Runtime.dynCall (http://khanfusiion3.github.io/index.js:331:39)
at http://khanfusiion3.github.io/index.js:8107:21
at Object.Browser.mainLoop.runIter (http://khanfusiion3.github.io/index.js:1873:13)
I also tried running it with the -s DEMANGLE_SUPPORT=1
option but the other errors didn't stop, so it still failed.
Any help on what's causing the errors and how to fix them?