# State of Compilation to Single Executable for Julia

**URL:** <https://discourse.julialang.org/t/state-of-compilation-to-single-executable-for-julia/30792>\
**Category:** General Usage\
**Created:** [November 6, 2019, 1:58pm UTC](https://discourse.julialang.org/t/state-of-compilation-to-single-executable-for-julia/30792 "2019-11-06T13:58:45Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Usor](https://avatars.discourse-cdn.com/v4/letter/u/8dc957/32.png) [@Usor](https://discourse.julialang.org/u/Usor)\
**Post date:** [November 6, 2019, 1:58pm UTC](https://discourse.julialang.org/t/state-of-compilation-to-single-executable-for-julia/30792/1 "2019-11-06T13:58:45Z")

</div>

This seems like the right forum part to post this to, but please put it to the correct one if necesssry.

I saw some messages on the forum about compiling to executables, but nothing about the current state.

- What is the current state?

- Is PackageCompiler.jl ready for convenient everyday use to produce single fully functional binaries needing no fiddling?

---

<div class="post-metadata">

**Author:** ![dhazeghi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dhazeghi/32/7107_2.png) [@dhazeghi](https://discourse.julialang.org/u/dhazeghi)\
**Post date:** [November 6, 2019, 5:12pm UTC](https://discourse.julialang.org/t/state-of-compilation-to-single-executable-for-julia/30792/2 "2019-11-06T17:12:25Z")

</div>

My experience (1.1 and 1.2 with PackageCompiler) has been that it works well - we are using the binaries in production and the process to generate them is simple (no manual tweaks). But there are some caveats.

1. Compilation is slow - 3+ minutes for even trivial applications. That means if/when I encounter a bug, either with the compiler or with the resulting binary, it can be a slow process to find a fix/workaround.
2. Binaries are large because they basically include the entire Julia runtime (~180MB each).

So I’d say if you can live with those limitations, it’s a good solution.

---

<div class="post-metadata">

**Author:** ![Ratingulate](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ratingulate/32/9242_2.png) [@Ratingulate](https://discourse.julialang.org/u/Ratingulate)\
**Post date:** [November 6, 2019, 6:36pm UTC](https://discourse.julialang.org/t/state-of-compilation-to-single-executable-for-julia/30792/3 "2019-11-06T18:36:42Z")

</div>

@Usor here’s the next gen package compiler [https://github.com/KristofferC/PackageCompilerX.jl](https://github.com/KristofferC/PackageCompilerX.jl)

It’s still a WIP

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [November 6, 2019, 6:41pm UTC](https://discourse.julialang.org/t/state-of-compilation-to-single-executable-for-julia/30792/4 "2019-11-06T18:41:53Z")

</div>

That is mostly a playground for me so I wouldn’t look too much there (especially not at this stage)

---

<div class="post-metadata">

**Author:** ![Usor](https://avatars.discourse-cdn.com/v4/letter/u/8dc957/32.png) [@Usor](https://discourse.julialang.org/u/Usor)\
**Post date:** [November 7, 2019, 1:30pm UTC](https://discourse.julialang.org/t/state-of-compilation-to-single-executable-for-julia/30792/5 "2019-11-07T13:30:02Z")

</div>

Thanks. That I cannot live with, I think.

---

<div class="post-metadata">

**Author:** ![Usor](https://avatars.discourse-cdn.com/v4/letter/u/8dc957/32.png) [@Usor](https://discourse.julialang.org/u/Usor)\
**Post date:** [November 7, 2019, 1:30pm UTC](https://discourse.julialang.org/t/state-of-compilation-to-single-executable-for-julia/30792/6 "2019-11-07T13:30:41Z")

</div>

Thanks. I think I’ll keep an eye on that.

---

<div class="post-metadata">

**Author:** ![Usor](https://avatars.discourse-cdn.com/v4/letter/u/8dc957/32.png) [@Usor](https://discourse.julialang.org/u/Usor)\
**Post date:** [November 7, 2019, 1:33pm UTC](https://discourse.julialang.org/t/state-of-compilation-to-single-executable-for-julia/30792/7 "2019-11-07T13:33:06Z")

</div>

What is exactly necessary to speed up development of this state?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [November 7, 2019, 1:38pm UTC](https://discourse.julialang.org/t/state-of-compilation-to-single-executable-for-julia/30792/8 "2019-11-07T13:38:08Z")

</div>

Nothing really, but it shouldn’t take too long.

I just want to point out that even with a perfectly working PackageCompiler, it will take a while before you will be able to create functional binaries without fiddling if you want to use a lot of packages. That is because many packages encodes things like absolute paths in their source code (by using the `build` step of package install to create a file with absolute paths that is then included). This means that they are fundamentally non-relocatable. Fortunately, we have something called the Artifact system in 1.3 which should make the build step pretty much obsolete. It might take a while for packages to start using that and for that new system to work perfectly though.

---

<div class="post-metadata">

**Author:** ![Usor](https://avatars.discourse-cdn.com/v4/letter/u/8dc957/32.png) [@Usor](https://discourse.julialang.org/u/Usor)\
**Post date:** [November 7, 2019, 1:52pm UTC](https://discourse.julialang.org/t/state-of-compilation-to-single-executable-for-julia/30792/9 "2019-11-07T13:52:12Z")

</div>

Thanks. In your reasonable estimation, considering all the knowledge you have, if I were to ask you how long it would be before this state is achieved, what would you say? A year?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [November 7, 2019, 2:12pm UTC](https://discourse.julialang.org/t/state-of-compilation-to-single-executable-for-julia/30792/10 "2019-11-07T14:12:14Z")

</div>

It depends a bit what you want. If it is just a simple script or packages that are simple and behave well when it comes to relocatability then on the order of a month maybe. After that, it depends a lot on how the ecosystem will behave when it comes to adopting artifacts and “jll” packages (which are binaries and libraries built on top of the artifact system)

---

<div class="post-metadata">

**Author:** ![Usor](https://avatars.discourse-cdn.com/v4/letter/u/8dc957/32.png) [@Usor](https://discourse.julialang.org/u/Usor)\
**Post date:** [November 7, 2019, 2:53pm UTC](https://discourse.julialang.org/t/state-of-compilation-to-single-executable-for-julia/30792/11 "2019-11-07T14:53:19Z")

</div>

Excellent.

---

<div class="post-metadata">

**Author:** ![vpetukhov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vpetukhov/32/12954_2.png) [@vpetukhov](https://discourse.julialang.org/u/vpetukhov)\
**Post date:** [November 13, 2019, 7:37am UTC](https://discourse.julialang.org/t/state-of-compilation-to-single-executable-for-julia/30792/12 "2019-11-13T07:37:12Z")

</div>

Do you use it on Mac or on Linux? For the later I couldn’t even make transferable app from the examples. Maybe I did something wrong though.

---

<div class="post-metadata">

**Author:** ![dhazeghi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dhazeghi/32/7107_2.png) [@dhazeghi](https://discourse.julialang.org/u/dhazeghi)\
**Post date:** [November 13, 2019, 5:35pm UTC](https://discourse.julialang.org/t/state-of-compilation-to-single-executable-for-julia/30792/13 "2019-11-13T17:35:20Z")

</div>

I’m building under Linux.

It’s probably worth starting a new thread if you have specific errors you’re trying to debug. The module dependencies you have do make a big difference.

As a basic example though:

```julia
$ cat ./hello.jl
Base.@ccallable function julia_main(ARGS::Vector{String})::Cint
    println("Hello Julia")
    return 0
end
$ PKGDIR=$(julia -e 'println(abspath(joinpath(dirname(Base.find_package("PackageCompiler")),"..")))')
$ julia $PKGDIR/juliac.jl -vae ./hello.jl
$ /tmp/builddir/hello

```

Binary will run wherever, provided /tmp/builddir/hello.so and libjulia.so are present on the target system.

---

<div class="post-metadata">

**Author:** ![vpetukhov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vpetukhov/32/12954_2.png) [@vpetukhov](https://discourse.julialang.org/u/vpetukhov)\
**Post date:** [November 15, 2019, 11:26pm UTC](https://discourse.julialang.org/t/state-of-compilation-to-single-executable-for-julia/30792/14 "2019-11-15T23:26:24Z")

</div>

Thanks for the answer! My bad, I forgot that I was actually using ApplicationBuilder.jl, which wraps PackageCompiler. And there I even opened an [issue](https://github.com/NHDaly/ApplicationBuilder.jl/issues/30), but got no response. But you’re right, here is not the best place for this discussion.
