使用 ApplicationBuilder.jl 从 Julia 代码构建独立应用程序

Rez*_*aei 2 julia

我正在尝试学习如何使用 ApplicationBuilder.jl 为 Windows 构建独立的完全独立的应用程序。例如,以下函数可能是应用程序的代码:

function Hello()
    println("Hello World")
end
Run Code Online (Sandbox Code Playgroud)

然后根据 ApplicationBuilder 文档,整个事情应该围绕一个 main 函数,如下所示:

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

当我运行

using ApplicationBuilder
build_app_bundle("D:\\Julia\\my_julia_main.jl", appname="Hello")
Run Code Online (Sandbox Code Playgroud)

它给了我以下错误:

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
Run Code Online (Sandbox Code Playgroud)

“build_executable 未定义”是什么意思以及如何修复它?

ffe*_*tte 5

TLDR:我建议PackageCompiler直接使用。文档写得很好,这部分特别解释了如何构建应用程序。

最小应用程序的框架可以在这里找到。它归结为创建一个包(名为eg Hello),其顶级模块如下所示:

# 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
Run Code Online (Sandbox Code Playgroud)

编译脚本如下所示:

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
Run Code Online (Sandbox Code Playgroud)



ApplicationBuilder您收到的错误来自于依赖的事实PackageCompiler,它在过去几个月中进行了完全重写。

ApplicationBuilder似乎是在考虑 v0.6.3 的情况下编写的PackageCompiler,但它没有设置兼容性界限,并且您可能PackageCompiler在系统上安装了最新的可用版本,其 API 已更改并且不被ApplicationBuilder.

您可能想要提交问题ApplicationBuilder,但与此同时,如果您确实想继续使用它,您可能需要尝试降级PackageCompiler到旧版本,例如 0.6.3。