gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 08:45:06 57 4
gpt4 key购买 nike

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

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

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

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

当我运行时

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

它给了我以下错误:

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

“build_executable not Defined”是什么意思以及如何修复它?

最佳答案

TLDR:我建议使用 PackageCompiler 直接。documentation写得很好,并且this part特别解释了如何构建应用程序。

最小应用的骨架可以参见here 。归结为 creating a package (例如 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

编译脚本如下所示:

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



您收到的错误来自 ApplicationBuilder取决于 PackageCompiler ,在过去几个月里进行了彻底重写。

ApplicationBuilder似乎是用 PackageCompiler 写的v0.6.3 记住,但它没有设置兼容性界限,您可能安装了最新的可用 PackageCompiler您系统上的版本,其 API 已更改且 ApplicationBuilder 不知道.

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

关于julia - 使用 ApplicationBuilder.jl 从 Julia 代码构建独立应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61796964/

57 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com