Using ApplicationBuilder.jl to build standalone apps from Julia code

Viewed 842

I'm trying to learn how to use ApplicationBuilder.jl to build a standalone fully independent application for windows. for example, the following function could be the code for the app:

function Hello()
    println("Hello World")
end

then based on the ApplicationBuilder documentation the whole thing should be wrapped around a main function like this:

include("helloexe.jl") #address of the file containing the above Hello() function
Base.@ccallable function julia_main(ARGS::Vector{String})::Cint
    return Hello()
end

When I run the

using ApplicationBuilder
build_app_bundle("D:\\Julia\\my_julia_main.jl", appname="Hello")

it gives me the following error:

build_app_bundle("D:\\Julia\\my_julia_main.jl", appname="Hello")
[ Info: Building at path D:\Julia\builddir\Hello
[ Info: Copying resources:
[ Info: Copying libraries
ERROR: UndefVarError: build_executable not defined
Stacktrace:
 [1] build_app_bundle(::String; resources::Array{String,1}, libraries::Array{String,1}, builddir::String, appname::String, create_installer::Bool) at C:\Users\Reza\.julia\packages\ApplicationBuilder\kMUzZ\src\bundle.jl:44
 [2] top-level scope at REPL[25]:1

What does 'build_executable not defined' mean and how can I fix it?

1 Answers

TLDR: I would advise to use PackageCompiler directly. The documentation is well written, and this part in particular explains how to build an application.

The skeleton of minimal application can be found here. It boils down to creating a package (named e.g. Hello), whose top-level module looks like this:

# file /path/to/Hello/src/Hello.jl
module Hello

function julia_main()
    try
        real_main()
    catch
        Base.invokelatest(Base.display_error, Base.catch_stack())
        return 1
    end
    return 0
end

function real_main()
    println("Hello World!")
end

end #module Hello

The compilation script then looks like:

using PackageCompiler
create_app("/path/to/Hello",         # this is the directory where Project.toml resides
           "/path/to/HelloCompiled") # target directory where you want your compiled app to be generated



The error you're getting comes from the fact that ApplicationBuilder depends on PackageCompiler, which underwent a complete rewrite in the past few months.

ApplicationBuilder seems to have been written with PackageCompiler v0.6.3 in mind, but it does not set compatibility bounds and you probably installed the latest available PackageCompiler version on your system, whose API has changed and is not known by ApplicationBuilder.

You might want to file an issue with ApplicationBuilder, but in the meantime, if you really want to keep using it, you might want to try and downgrade PackageCompiler to an old version like 0.6.3.

Related