DllNotFoundException in build but not editor

I’m doing an experimental project to see if the Julia language can be integrated into Unity.
I downloaded the 64 bit version of Julia and included it with my project, and it works fine. In the editor I am able to call Julia scripts with P/Invoke to the Julia C API, and pass data between C# and Julia. In addition, this is a project in VR (HTC Vive). However, when I build and run the project, I get this:

Fallback handler could not load library … /Some/Path/Here/
(and it looks in the Mono folder even though I didn’t specify that when searching for the dll).

I got that error with the 32 built version of Unity. When I build it with the 64 bit version, it crashes before any errors can even be loaded to the output log. I used Dependency Walker to check for dependency issues (even though I believe it only looks at static dependencies), and there is no difference between the libjulia.dll in the Assets folder and the libjulia.dll in the _Data/Plugins folder. I tried moving all of the dependent dlls into the Project folder next to the executable but that didn’t work either. Does anyone have any idea of what to do? Looking at other posts, I’m fairly sure it’s a dependency issue, but I don’t understand what the difference would be between the editor and standalone build. I don’t want to move things into the actual unity editor folder.

I managed to find the answer. jl_init requires that sys.dll be located in /lib/julia/ so that it can find it. Otherwise, it won’t load it even if the dll is in the same folder as libjulia.dll.

Another thing. Setting the folder of libjulia.dll in the PATH environment variable was also necessary. using LoadLibrary to load the other dlls was also helpful as it prevented libjulia.dll from not being found in the editor upon the first run of the program.

Julia (0.5.2) can now be officially used in Unity :slight_smile: