I can't get an external dll to work when building for webGL
I have developed a game that calls functions from an external dll developed in c#, which also depends on two more dlls.
It works fine when built for windows but when I build and test the software in WebGL the software runs but external dll functions seem not to work. An important detail is that the building folder for windows contains all the external dlls in BuildFolder\BuildFolder_Data\Managed, but the folder built for WebGL does not contain any of such libraries.
Can anyone help me on this issue? Thank You.
Answer by Bunny83 · Jul 20, 2020 at 12:08 AM
WebGL is an AOT platform. So all code is compiled ahead of time. Unity uses it's own IL2CPP converter to convert all managed IL code to native C++ code which is finally run in a virtual machine inside javascript. So all of you managed code will be compiled to native code. That's also the reason why you can't use any IL code that depends on dynamic code generation.
So saying you use some external DLL just won't cut it. Without knowing what DLLs you try to use we can't really help you. Keep in mind that WebGL runs in a secured environment inside the browser. Many things simpy do not work. For example: file access, .NET sockets, any direct hardware access, any direct OS API access, etc
Answer by lfbarcelo · Jul 22, 2020 at 02:23 PM
Thank you @Bunny83 for your reply. The dll is a quite simple fluid mechanics engine developed in C#.
Instead of pre-compiling it I could just insert it as a script in my Unity project since it is already C# and that would definitely fix it, but the issue is that within that engine I use another .NET library for linear system solving called Accord Math. This library is open source but it is huge and adding it as Unity scripts is not easy at all.
I don't think I am using any of the things you mention that would not work.
Any ideas would be really helpful, thanks in advance.
Answer by lfbarcelo · Jul 23, 2020 at 10:32 PM
I checked again, and my library works fine but the Accord Math library does not.
Every function from my external engine is called correctly but there is one line where I use a function named "solve" (http://accord-framework.net/docs/html/M_Accord_Math_Matrix_Solve_4.htm) that is a function from the Accord Math library. That call seems to be completely ignored and no warning or error is issued.
Keep in mind that this problem only happens when building for WebGL.
Your answer
Follow this Question
Related Questions
I can't get an external dll to work when building for webGL 0 Answers
Emscripten's linking support error when i use clientwebsocket 0 Answers
WebGL Build don't work 0 Answers
Installation Problem 0 Answers
JSLib - Get a reference to the player 0 Answers