Can elixir or erlang programs be compiled to a sta

2019-03-10 20:07发布

It sees 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)

3条回答
Melony?
2楼-- · 2019-03-10 20:35

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?

查看更多
疯言疯语
3楼-- · 2019-03-10 20:39

You can use tools like rebar to generate a release that also contains the erts, which makes it possible to run said release on a machine where erlang is not installed. But the erts included corresponds to the operating system on which the release was built, i.e. windows binaries if built on windows.

查看更多
\"骚年 ilove
4楼-- · 2019-03-10 20:45

Make sure you checkout Distillery https://github.com/bitwalker/distillery It does what you need, without having to deal with Rebar.

Add this to your mix.exs file's dependencies then run mix release. defp deps do [{:distillery, "~> 0.9"}] end

Their documentation is great. https://hexdocs.pm/distillery/home.html

查看更多
登录 后发表回答