# Compiling a Julia package to a shared library

**URL:** <https://discourse.julialang.org/t/compiling-a-julia-package-to-a-shared-library/18815>\
**Category:** General Usage\
**Created:** [December 18, 2018, 10:30pm UTC](https://discourse.julialang.org/t/compiling-a-julia-package-to-a-shared-library/18815 "2018-12-18T22:30:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LewisHein](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lewishein/32/5690_2.png) [@LewisHein](https://discourse.julialang.org/u/LewisHein)\
**Post date:** [December 18, 2018, 10:30pm UTC](https://discourse.julialang.org/t/compiling-a-julia-package-to-a-shared-library/18815/1 "2018-12-18T22:30:27Z")

</div>

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)

Thanks!

---

<div class="post-metadata">

**Author:** ![Pbellive](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pbellive/32/3604_2.png) [@Pbellive](https://discourse.julialang.org/u/Pbellive)\
**Post date:** [December 18, 2018, 10:47pm UTC](https://discourse.julialang.org/t/compiling-a-julia-package-to-a-shared-library/18815/2 "2018-12-18T22:47:01Z")

</div>

I would have a look at [PackageCompiler](https://github.com/JuliaLang/PackageCompiler.jl). 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.

---

<div class="post-metadata">

**Author:** ![LewisHein](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lewishein/32/5690_2.png) [@LewisHein](https://discourse.julialang.org/u/LewisHein)\
**Post date:** [December 18, 2018, 10:51pm UTC](https://discourse.julialang.org/t/compiling-a-julia-package-to-a-shared-library/18815/3 "2018-12-18T22:51:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Pbellive](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pbellive/32/3604_2.png) [@Pbellive](https://discourse.julialang.org/u/Pbellive)\
**Post date:** [December 18, 2018, 11:20pm UTC](https://discourse.julialang.org/t/compiling-a-julia-package-to-a-shared-library/18815/4 "2018-12-18T23:20:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![LewisHein](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lewishein/32/5690_2.png) [@LewisHein](https://discourse.julialang.org/u/LewisHein)\
**Post date:** [December 18, 2018, 11:37pm UTC](https://discourse.julialang.org/t/compiling-a-julia-package-to-a-shared-library/18815/5 "2018-12-18T23:37:35Z")

</div>

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