How to create an exe file from julia code?

Hi all,
I am new to julia. I just started loving this language at first sight, Elegant ! My area of interest is windows desktop applications. I just set up all the beginning steps in atom and execute my Hello World app. But now, i want to convert this code to an exe file. There is no use of julia for me if i cannot create an exe file. Please help me.

4 Likes

this is the most feared question of the community at the moment, there’s no ‘real-world usable’ approach – just like python, unless you just ask user to have python or course. The closest you can get is: GitHub - JuliaLang/PackageCompiler.jl: Compile your Julia Package

also see discussion here:

3 Likes

Thanks for the quick reply. I have read the instructions on the github page of PackageCompiler. But some points are not very clear,
Where i need to put the ArgParse ? I am strck without proper information
My cmd window says that Package PackageCompiler is not found in current path. I dont know wich path. I am confused. Please help.

Lot of information are given in github page of PackageCompiler. But i didnt understand that where i can use the "build_executable(“hello.jl”, “hello”) command. In CMD or in Julia prompt ?

Hi, it’s Julia prompt

I have tried but it does not work.

Why do you NEED an exe? (Just curious.)

1 Like

@PetrKryslUCSD, exe file are very useful to share tools with people that are not computer scientist and have never done a single program. Moreover some packages are not always retro compatible and a software can stop running after an update. (the problem is the same with R). For this reason I often make the choice to use Go and cross-compilation instead of Julia (even if I program faster in Julia).

11 Likes

This is why we have Manifest.toml files, that allow to specify exactly the version of the package we would like to use.

Given that the installation of julia binaries is very easy across many platforms I wonder, if it wouldn’t be an easy solution to write a little script for each platform that downloads the julia binaries and the package/script you want to share and potentially even a clickable script to run your julia code.
If it is just for sharing I don’t see a reason for exe file.

But exe files have other advantages, like shorter “time to first plot”.

3 Likes

I think this problem would be solved if you were to distribute Julia with a package environment. The environment can take care of the proper versions of all the packages.
On Windows, one could distribute a batch file that would run Julia, set up the environment, and run the Julia code.

2 Likes

@jbrea thank you very much for your answer, I did not try Manifest.toml and I will have a look :wink:

To give you more details about some problems I had with sharing Julia tools in the past (I confess that I only use Linux and MS windows is a nightmare for me) :
I had for example some windows 7 users that did not manage to install some Julia package because for some reasons a version of windows 7 could not access to github without a Microsoft patch, when I tested this patch it was not working…

On the same platform when some Julia version (I don’t remember the number) was uninstalled, and a new version was installed, it was not possible to make a link between .jl files and the julia.exe file, because the uninstall software did not remove all the entries in the registry database. As a result when the user click on the jl file it was not working. So it was necessary to clean that by hand using regedit, and then do a fresh install, so imagine how all this is difficult for somebody with very limited computer skills, he just gives up…

With a simple exe in go the user click and it works and I don’t have to study all the windows-related problems :slight_smile:

5 Likes

I see. Yeah, that sounds annoying. I never tried sharing with Windows users so far, but I am warned now…

I know there has been talk on Slack about fixing some Windows problems, but it’s hard to imagine support for Windows 7 will ever be what it is on Linux.

1 Like

@Zach_Christensen, of course I continue using Julia because it is one of my favorite language :wink:

I recently install one of my tool on windows 10 and everything worked fine (package download was easy) so I have the feeling that the situation has improved (but I did not try to desintall - reinstall Julia to see if the .jl file can be linked with the new julia.exe file)

1 Like

Ok. Thanks

In windows, if you double clicked on a julia file, it won’t work. We need exe file for that,

@vinod_kc The first time you click on a .jl file on windows, you have to link it with julia.exe binary. Then, Julia will start automatically when you click on a .jl file :slight_smile:

1 Like

No, you don’t. See below. Also, you can distribute a batch file, which will call Julia etc.

I am a hobby programmer. I tried python and quit later. Now i am using, VB.Net, Nim, D, & Rust. I am interested to experiment with new languages but if it is not capable to make an exe, then it is useless for me. I can’t even send the programs to my friends to try. However, i love the syntax of Julia.

5 Likes

If i send the “Myprogram.jl” and a batch file to my friend who had not installed Julia on his/her machine, then does it work ?