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

使用ApplicationBuilder.jl从Julia代码构建独立应用程序,julia,Julia,我正在尝试学习如何使用ApplicationBuilder.jl为windows构建独立的完全独立的应用程序。例如,以下函数可能是应用程序的代码: function Hello() println("Hello World") end 然后,根据ApplicationBuilder文档,整个过程应该围绕以下主要功能展开: include("helloexe.jl") #address of the file containing the above Hello() function B

我正在尝试学习如何使用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
# 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 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\u executable not defined”是什么意思?我如何修复它?

TLDR:我建议直接使用。编写得很好,特别是解释了如何构建应用程序

可以找到最小应用程序的框架。它归结为(命名为,例如,
Hello
),其顶层模块如下所示:

include("helloexe.jl") #address of the file containing the above Hello() function
Base.@ccallable function julia_main(ARGS::Vector{String})::Cint
    return Hello()
end
# 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
所依赖的事实,它在过去几个月内经历了完全的重写

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


您可能想向ApplicationBuilder提交一个问题,但与此同时,如果您真的想继续使用它,您可能想尝试将
PackageCompiler
降级到旧版本,如0.6.3。

我试图降级
PackageCompiler
,但它给了我一个错误。我也尝试过使用PackageCompiler本身,但文档对我来说并不清楚<代码>ApplicationBuilder文档更易于理解和使用!我尝试添加一个示例,解释如何使用PackageCompiler构建应用程序。我不确定它是否比文档中已有的内容更清楚,但至少让我们尝试一下……顺便说一句,我认为大多数软件包开发人员都欢迎这样的问题:“我尝试过使用您的软件包,但文档中的那部分内容太难理解,我最终没有实现我想要的”。只有新用户才能提供如此有价值的见解,因此,如果您有时间花在这方面,我鼓励您提交一些问题,解释是什么让您感到困惑。。。提前谢谢!谢谢你的帮助,我觉得你的解释清楚多了!我提交了一个关于我遇到的
ApplicationBuilder
错误的问题。我不认为提交一个关于不理解文档的问题是很常见的,是吗?你创建了一个包,还是仅仅是一个源文件?您确实需要一个包,它是一组源文件,以及描述软件依赖关系的
Project.toml
Manifest.toml
文件。生成包的最简单方法是使用
Pkg.generate
,如前所述。