WebGL with C++ static library

Is it possible to use C++ static library for Unity WebGL?

First, I generate the llvm bitcode by using “clang -emit-llvm -o libhello_webgl.bc -c hello_webgl.cpp”
Second, I drop this libhello_webgl.bc in the floder “Assets”–“Plugins”–“WebGL”
Third, I create the C# script to import this function like this:
[DllImport(“__Internal”)]
private static extern int sum_dll_webgl(int x, int y);

Unfortunately, the error message is “libhello_webgl.bc is not valid according to llvm-nm, can not link”

If I use the C++ source code instead of this static library, it works.

Thank you for your suggestion.

This forum is dead?
I solved this problem, the reason is the version of emscripten, the default version in Unity is very old.

1 Like

Yes, you should use emscripten to build the static lib.
And it’ll be helpful if you’ll write here how you solved it…
emscripten version? build command line?
Thanks