How to install PackageCompiler

I want to install the PackageCompiler, so that I can execute juliac.jl -vae --compile=all hello.jl.

Here is how I have done it:

julia> using Pkg

julia> Pkg.add("PackageCompiler")

Here is a simple script called hello.jl:

module Hello

Base.@ccallable function julia_main(ARGS::Vector{String})::Cint
    println("hello, world")
    @show sin(0.0)
    return 0
end

end

In order to compile it, I use:

julia ~/.julia/packages/PackageCompiler/oT98U/juliac.jl -vae --compile=all hello.jl

This creates an executable that can be executed as follows:

$ ./builddir/hello
hello, world
sin(0.0) = 0.0

So everything seems to work.

But is there a better way to call the juliac.jl? The README for PackageCompiler says I should be able to run it with just juliac.jl -h. As you can see, I have to use julia ~/.julia/packages/PackageCompiler/oT98U/juliac.jl -h which seems ugly to me.

I think not. But you can always copy the juliac.jl file to another location which is “better”. If you choose your home directory, then you will only need to execute julia ~/juliac.jl ...

EDIT: Much better than copying is to create a symbolic link. That way, you will have the new versions when you update the package.

1 Like

OT but no, because the new version of the package will not be located in the same folder.

Oh… then, no symlink :smile:

just run is O.K. for me

using PackageCompiler
build_executable("hello.jl")

This is no longer possible? juliac.jl is not available right now, it’s it?

The package was rewritten from scratch so instructions from before Feb 2020 are no longer valid. See the current docs.