Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a production ready binary from Julia code

I have a Julia program that inputs a csv and transforms the data via a bunch of functions, and outputs a csv file. I want to turn this into a binary so that I can run on different machines without having the source code on different machines.

I am looking at PackageCompiler.jl, but I can't find any understandable documentation for creating a binary app. I am trying:

using PackageCompiler

@time create_app("JuliaPrograms", "test"; precompile_execution_file="script.jl")

The file that contains all my code is script.jl and it lives in the dir JuliaPrograms, and I want the compiled binary to be named test.

When I run julia script.jl it performs as I want. I want to be able to run ./test with the same result.

However, I get this error:

ERROR: could not find project at "/Users/userx/JuliaPrograms/"

What am I doing wrong? Do I need some special project directory?

like image 760
connor449 Avatar asked Oct 22 '25 04:10

connor449


1 Answers

Per the docs here: https://julialang.github.io/PackageCompiler.jl/dev/apps.html#Creating-an-app-1 you need to make sure you define:

function julia_main()::Cint
  # do something based on ARGS?
  return 0 # if things finished successfully
end

a function called julia_main as the entry point to the app. You can find an example app here: https://github.com/JuliaLang/PackageCompiler.jl/tree/master/examples/MyApp

You may also want to check the location of the code itself. Is it being saved at "/Users/userx/JuliaPrograms/"? You can switch your directory in the Julia Reply by typing ; which will enter you into shell mode and then you can cd into the directory where your code is.