0

I already asked this in the Julia community discourse but asking it here as expect to find different audience.

I created a simple function as below:

#MyFunction.jl

__precompile__()
function MyFunction(x)
    y = x * 5
    y * 5
end

And found the pre-compiled files saved as:

/Users/hasan/.julia/compiled/v1.0/MyFunction.jl

Can I use/distribute this pre-compiled file with my main function without using the original file source code itself?

Hasan A Yousef
  • 22,789
  • 24
  • 132
  • 203

1 Answers1

1

These "compiled" files are only the lowering pass of Julia to byte code, which is not sufficient for stand-alone distribution. You might find this StackOverflow answer from Stefan Karspinski, one of the creators of Julia, useful for more details on the various layers of compilation inside Julia: https://stackoverflow.com/a/43456211/5504925

If you really want compiled code, your current best bet would be https://github.com/JuliaLang/PackageCompiler.jl. I'm not sure whether the package currently supports creating stand-alone binaries, or only intermediate forms, see also the introducting blog post by the author: https://medium.com/@sdanisch/compiling-julia-binaries-ddd6d4e0caf4.

jvz
  • 1,183
  • 6
  • 13