To compile an Erlang program, you need to:
- Open the terminal
- Run
erl
- Compile
c(<module name>).
with (or without) the.erl
extension. You can usepwd().
to check the current directory or usecd(<Dir>).
to change it. - Run the methods you export from the module with
<module name>:<method name>(<params>).
You can also use erlc foo.erl
to compile the module foo to foo.beam
.
You can then run foo using erl -noshell -s foo start -s init stop
, where start
is the method you want to call. -s init stop
is needed to terminate the Erlang session. If you are a fan of Makefiles, this is the way to go.