erlc

COMMAND

erlc

COMMAND SUMMARY

Compiler

DESCRIPTION

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.

EXPORTS

erlc flags file1.ext file2.ext...

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.

Generally Useful Flags

The following flags are supported:

-I directory

Instructs the compiler to search for include file in the specified
directory.
If not given, the compiler assumes that include files are located
in the current working directory.

-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.

-W

Enables warning messages.
Without this switch, only errors will be reported.

-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.

--

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.

Special Flags

The flags in this section are useful in special situations
such as re-building the OTP system.

-ilroot directory

Defines the root directory to be used for include_lib directives
in the Erlang compiler.
Defaults to the library directory of the emulator where the
compiler is run.

-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.

Supported Compilers

.erl

Erlang source code. It generates a .beam file.
The options -P, -E, and -S are equivalent to +'P',
+'E', and +'S', except that it is not necessary to include the single quotes to protect them
from the shell.
Supported options: -ilroot, -I, -o, -D, -v, -W, -b.

.yrl

Yecc source code. It generates an .erl file.
Use the -I option with the name of a file to use that file
as a customized prologue file (the fourth argument of the
yecc:yecc/4 function).
Supported options: -o, -v, -I (see above).

Script file. It generates a boot file.
Use the -I to name directories to be searched for application
files (equivalent to the path in the option list for
systools:make_script/2).
Supported options: -o.