New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PackageCompiler will not compile my (simple) Julia program to a static binary due to ArgParse errors #76
Comments
Ah, this one is easy! The problem isn't related to ArgParse at all, your julia program is simply missing
I've just noticed that's not mentioned anywhere on the README at all... I will send a PR up to fix that now. EDIT: oops, sorry, I hit "shift-enter" which apparently submits the comment, so it was submitted before I finished typing. Sorry! |
(You can see the problem here, in the output from
But there's a lot of output, so that message is hard to find, and it's also not clear what to do to fix it. |
I assumed there was an issue with |
Hmm, no I don't think so! I think it needs to execute the script, otherwise it might not know which code to compile! Take the following trivial example: if VERSION >= v"0.7"
include("mycode-0.7")
else
include("mycode-0.6")
end I have been thinking about global, "script-like" code as basically static, compile-time only logic, similar to c++ preprocessor macros, but way better because it's just normal, first class julia code. |
Thanks. Adding that julia_main at the end there got me an executable. And it does run and gives the correct result. But it also gives this warning every time I run it (how do I remove this?): WARNING: redefining constant JULIA_HOME Also, being new to Julia, this looks ugly: julia_main(ARGS::Vector{String})::Cint |
@NHDaly one option could be to be able to detect programmatically if a script is being statically compiled, and based on that either do or do not execute parts of code. |
Yay! Glad to hear it.
This is basically just some weirdness in If it bugs you, would you open an Issue about it? We could maybe look more into how to silence the warning in the meantime...
Yes, I agree, it is a bit ugly. The answer here is more or less that it's ugly because that function is being exposed as an interface that is callable from More precisely, the This is what an effectively similar function would look like in C: int julia_main(char* ARGS[]) { ... } You can see all the same parts are there (except that C doesn't have Vectors, just arrays, and no strings, just pointers to characters), they're just in a different order: D. In Julia, it's optional to declare the types of function parameters and return types. And in fact, it's often better not to. For example, the following function will work for any type whose values can be added together and divided by a float, and that's just not a thing that's possible to write in C: julia> average(a,b) = (a + b) / 2.0
julia> average(0.5, 1+2im) # here I'm averaging a float and a complex number. The author of average might not have even _known_ about complex numbers.
>> 0.75 + 1.0im But sometimes there are reasons to specify a type, such as specializing a function's behavior based on the types of its inputs. C interoperability is another such case. :) You can read more here if you're interested: Finally, if you want, you can simply omit the parameters if your program isn't going to use them and just declare it as |
@lucatrv Yeah I saw that as well. Actually, you can fix that by calling I've opened an issue specific to what you're trying to do here: #78 Let's talk more about it there! :) |
@isene: Also, yay! welcome to julia!! :) |
Amazing comment. Thanks for taking the time to explain this so thoroughly. |
Can this issue be closed? |
@lucatrv May I reactivate this not-yet-closed issue? The title corresponds to my initial issue. I had a program containing a Thanks to the above explanations, I understand now that my program should just define So I commented out the call to Now, with
etc. I double-checked that
Here is my build script:
(By the way, is that a correct way to write a build script? I couldn't find documentation giving examples of what kind of things should be put in a build script, just documentation saying that a project can have one in And I execute it as follows:
All the above is done from the
|
Actually, the Now my application compiles, and runs with its |
I am trying to compile my program to an executable on Linux using PackageCompiler - but can't get it to work on either Julia 0.6 or 0.7. In both cases it's ArgParse that creates the error, but different errors for the two versions. See the attached files for detail (I renamed my program to be compiled here from O6.jl to O6.txt due to limitations of uploading .jl files)
O6.txt
julia06.txt
julia07.txt
The text was updated successfully, but these errors were encountered: