Julia - Single File Executable
12/01/2025, MonSelf-Contained Binary
Installing JuliaC can help you compile your julia application to a single self-contained binary.
The following instructions are adapted from
https://julialang.org/blog/2025/10/julia-1.12-highlights/index.html#new_--trim_feature
Make sure clang or gcc is installed.
Enter into the julia cli to create a project with pkg
generate MyProject
within the src/MyProject.jl file, make sure a main function is defined
module MyProject
function @main(ARGS)
println(Core.stdout, "Hello World!")
return 0
end
end
Within pkg, download the JuliaC compiler into a dev folder (since JuliaC isn't in the package registry) before installing it as an app.
dev https://github.com/JuliaLang/JuliaC.jl
app add JuliaC
Exit julia cli and add the JuliaC to your path for general availability.
echo 'export PATH="$HOME/.julia/dev:$PATH"' >> ~/.bashrc
source ~/.bashrc
juliac \
--output-exe app_test_exe \
--bundle build \
--trim=safe \
--experimental \
./MyProject
The output-exe flag option is still compatible on Linux.
When the binary is completely compiled, it will reside in a build folder that
is on the same level as the MyProject folder.
Execute the app with
./build/bin/app_test_exe