Hello,
It seems that PackageCompiler does not work with ARGS.
I tried several ways and none worked:
CASE 1:
In precompile_app.jl:
MyProgram.julia_main(["CHECK_DATA_1", "DEV"])
In MyProgram.jl:
module MyProgram
argument_list = ARGS
println("Length of arguments array: " * string(length(ARGS)))
println("Content of arguments array: ")
program_main()
# My Source Code
end
Base.@ccallable function julia_main(ARGS::Vector{String})::Cint
program_main()
return 0
end
end
When compiling with PackageCompiler, then I get this error message:
Failed to precompile MyProgram [8055130b-358c-4aa5-b077-72da6b1478e9] to C:\Users\sbbstm.julia\compiled\v1.8\MyProgram\jl_5E4F.tmp.
ERROR: LoadError: MethodError: no method matching julia_main()
Closest candidates are:
julia_main(::Vector{String}) at C:\JuliaWS\MyProgram\MyProgram\src\MyProgram.jl:890
CASE 2:
In precompile_app.jl:
MyProgram.julia_main()
In MyProgram.jl:
module MyProgram
argument_list = ARGS
println("Length of arguments array: " * string(length(ARGS)))
println("Content of arguments array: ")
program_main()
# My Source Code
end
Base.@ccallable function julia_main(ARGS::Vector{String})::Cint
program_main()
return 0
end
end
When compiling with PackageCompiler, then I get this error message:
Failed to precompile MyProgram [8055130b-358c-4aa5-b077-72da6b1478e9] to C:\Users\sbbstm.julia\compiled\v1.8\MyProgram\jl_517D.tmp.
ERROR: LoadError: MethodError: no method matching julia_main()
Closest candidates are:
julia_main(::Vector{String}) at C:\JuliaWS\MyProgram\MyProgram\src\MyProgram.jl:890
CASE 3:
In precompile_app.jl:
MyProgram.julia_main()
module MyProgram
argument_list = ARGS
println("Length of arguments array: " * string(length(ARGS)))
println("Content of arguments array: ")
program_main()
# My Source Code
end
julia_main()::Cint
program_main()
return 0
end
end
It compiles an creates a MyProgram.exe in the folder bin, but when starting the compiled MyProgram.exe, it does nothing related to ARGS!
It even does not write the result of these 2 lines, neither when I give arguments nor when i give no arguments when starting MyProgram.exe:
println("Length of arguments array: " * string(length(ARGS)))
println("Content of arguments array: ")
WITHOUT PackageCompiler.jl:
When starting the same source code as in CASE 3 without PackageCompiler and giving no args, then I get this here (that is what I expected and what is OK):
Length of arguments array: 0
Content of arguments array:
When starting the program (source code via Julia.exe) with arguments, such as “Julia.exe MyProgram.jl bla 123” then it works correctly. The output is:
Length of arguments array: 2
Content of arguments array:
bla
123
It seems that ARGS does not work with PackageCompiler.
Is there any workaround or bugfix?
My system:
- Winows 10 64 Bits
- Julia 1.8.5
- PackageCompiler v2.1.7
Thanks for your advices in advance!
Kind regards,
Miroslav Stimac