The erlc program provides a common way to run
all compilers in the Erlang system.
Depending on the extension of each input file, erlc
will invoke the appropriate compiler.
Regardless of which compiler is used, the same flags are used to provide parameters such as include paths and output directory.
The current working directory, ".", will not be included
in the code path when running the compiler (to avoid loading
Beam files from the current working directory that could potentially
be in conflict with the compiler or Erlang/OTP system used by the
compiler).
Erlc compiles one or more files.
The files must include the extension, for example .erl
for Erlang source code, or .yrl for Yecc source code.
Erlc uses the extension to invoke the correct compiler.
The following flags are supported:
-
-I directory
-
Instructs the compiler to search for include files in
the specified directory. When encountering an
-include or -include_dir directive, the
compiler searches for header files in the following
directories:
-
".", the current working directory of the
file server;
-
the base name of the compiled file;
-
the directories specified using the -I option.
The directory specified last is searched first.
-
-o directory
-
The directory where the compiler should place the output files.
If not specified, output files will be placed in the current working
directory.
-
-Dname
-
Defines a macro.
-
-Dname=value
-
Defines a macro with the given value.
The value can be any Erlang term.
Depending on the platform, the value may need to be
quoted if the shell itself interprets certain characters.
On Unix, terms which contain tuples and list
must be quoted. Terms which contain spaces
must be quoted on all platforms.
-
-Wnumber
-
Sets warning level to number. Default is 1.
Use -W0 to turn off warnings.
-
-W
-
Same as -W1. Default.
-
-v
-
Enables verbose output.
-
-b output-type
-
Specifies the type of output file.
Generally, output-type is the same as the file extension
of the output file but without the period.
This option will be ignored by compilers that have a
a single output format.
-
-hybrid
-
Compile using the hybrid-heap emulator. This is mainly useful
for compiling native code, which needs to be compiled with the same
run-time system that it should be run on.
-
-smp
-
Compile using the SMP emulator. This is mainly useful
for compiling native code, which needs to be compiled with the same
run-time system that it should be run on.
-
--
-
Signals that no more options will follow.
The rest of the arguments will be treated as file names,
even if they start with hyphens.
-
+term
-
A flag starting with a plus ('+') rather than a hyphen
will be converted to an Erlang term and passed unchanged to
the compiler.
For instance, the export_all option for the Erlang
compiler can be specified as follows:
erlc +export_all file.erl
Depending on the platform, the value may need to be
quoted if the shell itself interprets certain characters.
On Unix, terms which contain tuples and list
must be quoted. Terms which contain spaces
must be quoted on all platforms.
The flags in this section are useful in special situations
such as re-building the OTP system.
-
-pa directory
-
Appends directory to the front of the code path in
the invoked Erlang emulator.
This can be used to invoke another
compiler than the default one.
-
-pz directory
-
Appends directory to the code path in
the invoked Erlang emulator.