Compiling a Julia package to a shared library

Hey all,

I’m considering building some audio and image processing plugins to work in existing open-source software. Of course, I’d love to do this work in Julia, but these often need plugins that are shared libraries.

I know it used to be possible to statically compile Julia before 1.0. Is this still possible? The code generation options seem to have been removed or changed. (I didn’t find them in the docs and they produce an uninformative error when I try them)


I would have a look at PackageCompiler. I’m working on using it to build shared libraries now. On Windows I’ve tested that I can compile a simple shared library that includes some code from one of my own julia packages on one machine and then copy the library to another machine that doesn’t have julia, where I build a C++ executable and link it against the shared library with the julia functions. Requires shipping the julia libraries along with your shared libraries but it seems to work.

Are you using Julia 1.0? I looked at PackageCompiler.jl but I couldn’t tell if it would work on post 1.0 versions or not

Yes, I’ve been using it with julia 1.0.2. The --compile=all julia option seems to be broken on 1.0 but building a shared lib using the static_julia function from PackageCompiler using the keyword argument compile="yes", which ends up calling julia with the --compile=yes flag seems to work. I’ve also been passing a snoop file to PackageCompiler to make sure everything I need is getting compiled. I should add the caveat that I’m not a static julia/PackageCompiler expert, I’m just sharing what worked for me.

Thanks @Pbellive. If anything has worked for you yet, you’re more of an expert than I am