Creating fully self-contained and pre-compiled library

Thanks for the hints. Forgot to note that currently I’m developing on Windows (but will later deploy on linux; but want to have a proof-of-concept on Windows first). So I downloaded the portable nightly binaries (from today, 05:06) and tried to compile the hello-world example. That is, just the following in a .jl file:

function @main(args::Vector{String})::Cint
    println(Core.stdout, "Hello, World!")
    return 0
end

Compilation works fine, and I can see that the generated .exe depends on libjulia.dll and libjulia-internal.dll. So, put these two right next to the .exe such that they are found.

When I run the .exe, it errors out. Could get the following message (when I double-click the .exe instead of calling it from bash/cmd):

Sorry for the German. It says that the entrypoint with that very cryptic name cannot be found in libjulia-internal.dll. Any ideas what is going wrong?


Edit 1: went deeper into analysing dependencies. libjulia-internal depends on ...\mingw64\bin\libstdc++-6. So, I happened to have mingw64 installed / on the path and was not aware that this was required for juliac. For some reasons I had da very old version of it installed (from 2012 or so), but also changing to a recent one (14.2.0) does not solve the problem (but a different entrypoint is not found). For this version, it does not have available:

  • std::__once_functor
  • std::__get_once_mutex()
  • std::__set_once_functor_lock_ptr(std::unique_lock<std::mutex>*)

I then found the sentence “The msys2 libstdc+±6.dll appears to not have the needed symbols while the one distributed with Julia does.” in this thread. So, due to my installation of mingw64 being on the path, these libs are loaded.

If I remove my mingw64 installation from the PATH, four mingw64-libs are not found (atomic-1, gcc_s_seh-1, winpthread-1, stdc++-6). If I use those from the /bin folder of julia, I get a step further, namely calling the .exe providing console output about what else is missing (funnily I cannot find that these are missing using a dependency analyser on my .exe).

In the end, I get the .exe for the hello-world example to work (:slight_smile:) if these libs from <julia-root>/bin are available (besides the hello.exe):

  • hello.exe (1.648 MB)
  • libatomic-1.dll (0.256 MB)
  • libgcc_s_seh-1.dll (0.932 MB)
  • libjulia-internal.dll (14.556 MB)
  • libjulia.dll (0.214 MB)
  • libopenlibm.dll (0.523 MB)
  • libpcre2-8.dll (0.802 MB)
  • libstdc+±6.dll (25.018 MB)
  • libwinpthread-1.dll (0.323 MB)

For all binary-size guys out there, that’s 42.6 MB of libraries (almost exclusively made up by the two highlighted-in-bold-font ones).


Edit 2: I was calling the .exe from bash (on mingw64) before. Then the above libs are sufficient. If called from cmd/powershell, it complains about two other libs not being available, but still prints the “Hello world!” to the console. These libs are:

  • libgmp-10.dll (1.054 MB)
  • libmpfr-6.dll (2.505 MB)
3 Likes