I create an .exe file with Build_Executable function from PackageCompiler. It works very well if I run it from my computer. If I want to share the executable file and run it on another computer it doesnt work. I get this error message
fatal: error thrown and no exception handler available.
rec_backtrace at /home/Administrator/buildbot/worker/package_win64/build/src\stackwalk.c:94
record_backtrace at /home/Administrator/buildbot/worker/package_win64/build/src\task.c:217 [inlined]
jl_throw at /home/Administrator/buildbot/worker/package_win64/build/src\task.c:417
jl_errorf at /home/Administrator/buildbot/worker/package_win64/build/src\rtutils.c:77
jl_load_dynamic_library at /home/Administrator/buildbot/worker/package_win64/build/src\dlload.c:197
jl_get_library at /home/Administrator/buildbot/worker/package_win64/build/src/home/Administrator/buildbot/worker/package_win64/build/src\runtime_ccall.cpp:50
jl_load_and_lookup at /home/Administrator/buildbot/worker/package_win64/build/src/home/Administrator/buildbot/worker/package_win64/build/src\runtime_ccall.cpp:61
jlplt_g_type_init_7094 at C:\Users\fv973uv\Desktop\Executable\IFRS17.dll (unknown line) init__gtype at C:\Users\mehdi.barbouche.julia\packages\Gtk\RwVPb\src\GLib\signals.jl:329 init at C:\Users\mehdi.barbouche.julia\packages\Gtk\RwVPb\src\GLib\signals.jl:392
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2219
jl_apply at /home/Administrator/buildbot/worker/package_win64/build/src\julia.h:1571 [inlined]
jl_module_run_initializer at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:72
_julia_init at /home/Administrator/buildbot/worker/package_win64/build/src/home/Administrator/buildbot/worker/package_win64/build/src\init.c:832
.text at C:\Users\fv973uv\Desktop\Executable\IFRS17.exe (unknown line)
__tmainCRTStartup at /home/abuild/rpmbuild/BUILD/mingw-w64-crt\crt\crtexe.c:339
mainCRTStartup at /home/abuild/rpmbuild/BUILD/mingw-w64-crt\crt\crtexe.c:223
BaseThreadInitThunk at C:\Windows\System32\KERNEL32.DLL (unknown line)
RtlUserThreadStart at C:\Windows\SYSTEM32\ntdll.dll (unknown line)
To run a compiled julia executable on another machine, you’ll have to transfer the julia runtime libraries in addition to the exe itself. The new machine will have to be able to find a compatible libjulia.dll (in the lib directory of your julia installation) and all the dlls in the lib/julia directory if I’m not mistaken.
Looks like you are trying to build a package that uses Gtk. I’ve managed to relocate a Gtk application on mac OS but it’s not straightforward. The issue is that you need to move all the Gtk’s dll and external file in addition to the Julia ones. And the relative/absolute paths need to be correct. On mac OS you can modify libraries that depends on others to modify their paths, I’m not sure how it works on windows.
Other Julia packages might have similar issues, there’s sometimes hard-coded absolute paths that need to be taken care of.
Hi, thank you for your answer! No, I am actually looking for a generic way of generating a standalone .exe file from julia code that I could send to someone else who does not have julia installed. A simple code that would read some text input, do some calculations and generate some text or ideally also some plots output. I generally use DifferentialEquations, LinearAlgebra, SparseArrays.
I was able to compile that to an executable that runs on my computer with PackageCompiler, but not on others
What kind of error do you get, is it a missing library like above ? What I did for testing if my executable was portable was to temporarily rename my .julia folder, so if the executable was looking for files in there it would crash (testing each time on another computer is cumbersome).
The problem is that the package SpecialFunctions downloaded and installed a library on your machine in the build step when you added the package. You can see in the deps/deps.jl file in that package (in your package directory) that it wants to load the library:
Thank you for the tip on changing .julia folder to test on the same computer I will try to gather the missing dll files. It would be nice to be able to compile it down to a standalone .exe as with Fortran or C code.
Note there’s an option in ApplicationBuilder to copy libraries but I don’t know how well it works (it’s been developed for macOS I think). There’s a bit of work to be done to streamline this process, but not many people have tried ship executable it seems.
You can change the location of the library before the build. For example here I replace the hardcoded path to the library (something like /home/.../.julia/packages/.../libopenspecfun.so) to libopenspecfun.so (which then needs to be placed alongside the binary):
Base.eval(SpecialFunctions, :(openspecfun = basename(openspecfun)))
Then I could compile and just copy libopenspecfun.dll to the folder where the .exe runs. Then deps.jl needs to be changed back to its original form in order to use the other packages normally.
I guess that’s exactly what you did in a more elegant manner with that command, but I could not get it to work.