Hi
I am trying to create a Unity WebGL build with my c++ code. I have tried the following 2 methods to create Unity WebGL build.
- Create .bc file externally using emcc(emscripten) tool.
Even though I didn’t got any errors to compile my cpp files into one .bc file and even placing the .bc file in webgl folder in unity project Plugins folder. But when I run the build I get the following error.
Invoking error handler due to
Uncaught abort(“To use dlopen, you need to use Emscripten’s linking support, see Linking · emscripten-core/emscripten Wiki · GitHub”) at Error
at jsStackTrace (test-webgl.wasm.framework.unityweb:8:22295)
at stackTrace [Object.stackTrace] (test-webgl.wasm.framework.unityweb:8:22466)
at Object.onAbort (http://localhost/test-webgl/Build/UnityLoader.js:4:11047)
at abort (test-webgl.wasm.framework.unityweb:8:440553)
at _dlopen (test-webgl.wasm.framework.unityweb:8:153940)
at wasm-function[26622]:0x712d43
at wasm-function[27755]:0x7421f0
at wasm-function[27029]:0x725f91
at wasm-function[27028]:0x725f0c
at wasm-function[27031]:0x725ffd
at wasm-function[22381]:0x644125
at wasm-function[29361]:0x79913b
at dynCall_iiiii [Object.dynCall_iiiii] (test-webgl.wasm.framework.unityweb:8:421188)
at invoke_iiiii (test-webgl.wasm.framework.unityweb:8:310968)
at wasm-function[27081]:0x7271b9
at wasm-function[26547]:0x70fc34
at wasm-function[1742]:0x95e96
at wasm-function[1741]:0x95dc4
at wasm-function[5207]:0x1bdae4
at wasm-function[5204]:0x1bceb4
at wasm-function[7482]:0x2b5b02
at wasm-function[5628]:0x1efd40
at wasm-function[7908]:0x2e6d20
at wasm-function[7625]:0x2c442e
at wasm-function[7625]:0x2c4443
at wasm-function[7617]:0x2c3627
at wasm-function[7611]:0x2c1ca4
at wasm-function[29373]:0x7992b9
at dynCall_v [Object.dynCall_v] (test-webgl.wasm.framework.unityweb:8:428673)
at browserIterationFunc (test-webgl.wasm.framework.unityweb:8:158179)
at runIter [Object.runIter] (test-webgl.wasm.framework.unityweb:8:161240)
at Browser_mainLoop_runner (test-webgl.wasm.framework.unityweb:8:159702)
- Placing a single .cpp with all the includes of my cpp files.
In this case I further faced 2 problems.
a. If any of my cpp file which is further including third party library I get the following error. Even though I passed the include path of that third party library as emscripten argument using the Unity Editor API as following.
PlayerSettings.WebGL.emscriptenArgs = "-std=c++17 -ID:\\opencv-master\\opencv\\install\\include";
I get the following error.
stdout:
stderr:In file included from path_to_my_file_with_includes_in_unity_plugins_folder.cpp : 1 : path_to_my_cppfile_myfile.cpp:1:10: fatal error: ‘opencv2/opencv.hpp’ file not found#include <opencv2/opencv.hpp> ^~~~~~~~~~~~~~~~~~~~1 error generated.ERROR:root:compiler frontend failed to generate LLVM bitcode, halting
UnityEngine.GUIUtility : ProcessEvent(Int32, IntPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
b. I removed all the third party library includes from my cpp file in Plugins folder and Unity generated WebGL build successfully. but I got the same error as above.
Invoking error handler due to
Uncaught abort(“To use dlopen, you need to use Emscripten’s linking support, see Linking · emscripten-core/emscripten Wiki · GitHub”) at Error
at jsStackTrace (test-webgl.wasm.framework.unityweb:8:22295)
at stackTrace [Object.stackTrace] (test-webgl.wasm.framework.unityweb:8:22466)
at Object.onAbort (http://localhost/test-webgl/Build/UnityLoader.js:4:11047)
at abort (test-webgl.wasm.framework.unityweb:8:440553)
at _dlopen (test-webgl.wasm.framework.unityweb:8:153940)
at wasm-function[26622]:0x712d43
at wasm-function[27755]:0x7421f0
at wasm-function[27029]:0x725f91
at wasm-function[27028]:0x725f0c
at wasm-function[27031]:0x725ffd
at wasm-function[22381]:0x644125
at wasm-function[29361]:0x79913b
at dynCall_iiiii [Object.dynCall_iiiii] (test-webgl.wasm.framework.unityweb:8:421188)
at invoke_iiiii (test-webgl.wasm.framework.unityweb:8:310968)
at wasm-function[27081]:0x7271b9
at wasm-function[26547]:0x70fc34
at wasm-function[1742]:0x95e96
at wasm-function[1741]:0x95dc4
at wasm-function[5207]:0x1bdae4
at wasm-function[5204]:0x1bceb4
at wasm-function[7482]:0x2b5b02
at wasm-function[5628]:0x1efd40
at wasm-function[7908]:0x2e6d20
at wasm-function[7625]:0x2c442e
at wasm-function[7625]:0x2c4443
at wasm-function[7617]:0x2c3627
at wasm-function[7611]:0x2c1ca4
at wasm-function[29373]:0x7992b9
at dynCall_v [Object.dynCall_v] (test-webgl.wasm.framework.unityweb:8:428673)
at browserIterationFunc (test-webgl.wasm.framework.unityweb:8:158179)
at runIter [Object.runIter] (test-webgl.wasm.framework.unityweb:8:161240)
at Browser_mainLoop_runner (test-webgl.wasm.framework.unityweb:8:159702)
I hope I can get some response from Unity guys here. Thanks