erlc

Erlang compiler for BEAM bytecode

TLDR

Compile Erlang module
$ erlc [module.erl]
Compile to specific directory
$ erlc -o [ebin] [module.erl]
Compile with debug info
$ erlc +debug_info [module.erl]
Include header directory
$ erlc -I [include] [module.erl]
Compile multiple files
$ erlc [*.erl]
Show warnings as errors
$ erlc -Werror [module.erl]

SYNOPSIS

erlc [options] files...

DESCRIPTION

erlc is the Erlang compiler, converting Erlang source files (.erl) to BEAM bytecode (.beam). It's the standard way to compile Erlang modules.The compiler supports various options for optimization, debugging, and include paths. It's typically invoked through build tools like rebar3 but can be used directly.

PARAMETERS

-o directory

Output directory for compiled files.
-I directory
Add include directory.
-D name[=value]
Define macro.
-W level
Warning level.
-Werror
Treat warnings as errors.
+debug_info
Include debug information.
+native
Native code compilation (HiPE).
-b type
Output type (beam, asm, etc.).
-v
Verbose output.
-pa path
Add code path.

INSTALL

sudo apt install erlang-base
sudo apk add erlang27
sudo zypper install erlang27

CAVEATS

Requires Erlang/OTP installed. Native compilation deprecated in OTP 24+. Include paths must be specified explicitly. Module name must match filename.

HISTORY

erlc has been part of Erlang/OTP since its early releases. Erlang was developed at Ericsson by Joe Armstrong and others starting in 1986, released as open source in 1998. The compiler generates BEAM bytecode for the Erlang virtual machine.

SEE ALSO

erl(1)