Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Elixir or Erlang programs be compiled to a standalone binary?

It says that Elixir has a tool called elixirc and Erlang has a tool called erlc to compile modules for use. It says immediately after this that you can then run code with the elixir command line tool.

Is there a way to compile a binary executable with Elixir or Erlang? (one which I can chmod +x binary_name and then run from the same directory with ./binary_name)

like image 518
Mike H-R Avatar asked Aug 06 '15 16:08

Mike H-R


People also ask

Does elixir compile to binary?

You can use Elixir's built-in releases as of Elixir 1.9. It is a lightweight alternative to Distillery. Caveats: It will not create anything remotely like Go does with a single binary executable that you can run almost anywhere. Also your target will have to match the CPU architecture and OS.

Can you compile elixir?

You can compile an elixir file using the elixirc command. This will create a . beam file in the current directory for each module defined in your file. If you start iex in this directory your modules from the file will be available.

Is Erlang compiled?

Normally Erlang code is compiled ahead of time into BEAM bytecode. Depending on whether Erlang was started in embedded or interactive mode, the modules are either loaded on startup, or dynamically as they are referenced. If you are building a release, you basically have to compile ahead of time.


1 Answers

Escripts support that to some extent but you still need Erlang installed in your machine. See this answer for more information: Elixir or Hex portable package format?

like image 84
José Valim Avatar answered Sep 22 '22 02:09

José Valim