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
)
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.
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.
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.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With