Having Problems when creating an app

Hello, I am haivng problems when converting my code into an exe file. While I have to use isdefined function to check if there is an variable in my main environment such as ’ if isdefined(:term_symbol)', and the packagecompiler could not create an module let this fucntion to check, which eventually get the error message as: ‘head not found’. But this phrase is necessay for the rest of my code, is there any way to let exe run successful?

Hello @gugong, and welcome to the Julia community!

I’m afraid you haven’t given enough details for us to get started with.

Do I get it correctly that you are trying to compile a Julia script into an executable? AFAIK, to use PackageCompiler, you have to put all your code inside a module, and compile that module as a package. In theory, there shouldn’t be any issues with compiling isdefined calls, so I’m guessing that you’re attempting to check if a symbol is defined in a toplevel call in the Main module. While this works from the REPL, it won’t work as expected when compiled, because at the time of compilation, it’s not. I’m unsure about the specific error message you get. Please provide more context.

Thank you very much! Here is the details of my works:

I am trying to use julia to run this part of code which use a package called JWAS, and what I am doing is just put everything into a module and it seems that the function I used from JWAS uses the isdefined(main, symbol) (and getfield) and I try to modify this main into the module of the module named as MyModule containing my function and everything. But the exe shows the error message that MyModule not found. I am currently thinking of move the related function from JWAS into my main function in order to solve that question.

I briefly checked the source code of JWAS.jl, and it indeed checks for symbols defined in the Main module. At first glance, this seems like a poor design decision on behalf of the JWAS.jl developers, because it appears to limit its use to the Main module only. I could be wrong, though, I haven’t tried to use it myself.

Anyhow, in this case, the problem appears to caused by putting your own logic inside a module (or rather, the fact that JWAS.jl isn’t prepared for that), not by using PackageCompiler. I’m afraid I’d have to have a more in depth knowledge of JWAS.jl to figure out how to do this properly.

I found a new way to solve my question already, which is transfer my data into the function as a parameter. I think it will work, I will let you know the updates. Thank you very much!

1 Like