使用Emscripten,我一直在試圖將ImpulseEngine project by Randy Gaul (C++)編譯爲JavaScript程序。一旦我運行了Emscripten,我就會按照here所描述的教程進行操作。我遵循了所有步驟:將.cpp文件鏈接到.bc文件,然後將它們編譯成.js。使用Emscripten將C++ ImpulseEngine編譯爲JavaScript
這裏是我跑的命令列表:
的.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
注意-s LEGACY_GL_EMULATION=1
選項:這是用於啓用OpenGL功能。當然,當我跑的命令,我還收到了關於未解決的符號一些警告,因爲在這裏看到:
warning: unresolved symbol: glPointSize
warning: unresolved symbol: glRasterPos2i
warning: unresolved symbol: glutBitmapCharacter
warning: unresolved symbol: glutBitmap9By15
從理論上講,程序會失敗,現在不管接下來會發生什麼,但我想反正。它立即拋出一個錯誤並退出。這是記錄到控制檯的每個錯誤的列表:
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)
我也試圖與-s DEMANGLE_SUPPORT=1
選項運行它,但其他錯誤並沒有停止,所以它還是失敗了。
什麼是導致錯誤和如何解決它們的幫助?
它看起來像符號glPointSize,glRasterPos2i,glutBitmapCharacter和glutBitmap9By15未解決。正如你已經看到的。 – immibis