NAME¶erlc - 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 invokes 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, ".", is not included in the code path when running the compiler. This to avoid loading Beam files from the current working directory that could potentially be in conflict with the compiler or the Erlang/OTP system used by the compiler.
EXPORTS¶erlc flags file1.ext file2.ext...
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 files in the Directory. When encountering an -include or -include_lib 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 option -I; the directory specified last is searched first
- -o <Directory>:
- The directory where the compiler is to place the output files. Defaults to the current working directory.
- Defines a macro.
- Defines a macro with the specified 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 containing tuples and lists must be quoted. Terms containing spaces must be quoted on all platforms.
- Makes all warnings into errors.
- Sets warning level to Number. Defaults to 1. To turn off warnings, use -W0.
- Same as -W1. Default.
- Enables verbose output.
- -b <Output_type>:
- Specifies the type of output file. Output_type is the same as the file extension of the output file, but without the period. This option is ignored by compilers that have a single output format.
- Compiles using the SMP emulator. This is mainly useful for compiling native code, which must be compiled with the same runtime system that it is to be run on.
- Produces a Makefile rule to track header dependencies. The rule is sent to stdout. No object file is produced.
- -MF <Makefile>:
- As option -M, except that the Makefile is written to Makefile. No object file is produced.
- Same as -M -MF <File>.Pbeam.
- -MT <Target>:
- In conjunction with option -M or -MF, changes the name of the rule emitted to Target.
- -MQ <Target>:
- As option -MT, except that characters special to make/1 are quoted.
- In conjunction with option -M or -MF, adds a phony target for each dependency.
- In conjunction with option -M or -MF, considers missing headers as generated files and adds them to the dependencies.
- Signals that no more options will follow. The rest of the arguments is treated as filenames, even if they start with hyphens.
- A flag starting with a plus (+) rather than a hyphen is converted to an Erlang term and passed unchanged to the compiler. For example, option export_all 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 containing tuples and lists must be quoted. Terms containing spaces must be quoted on all platforms.
SPECIAL FLAGS¶The following flags are useful in special situations, such as rebuilding 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.
SUPPORTED COMPILERS¶The following compilers are supported:
- Erlang source code. It generates a .beam file.
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: -I, -o, -D, -v, -W, -b.
- Erlang assembler source code. It generates a .beam file.
Supported options: same as for .erl.
- Erlang core source code. It generates a .beam file.
Supported options: same as for .erl.
- Yecc source code. It generates an .erl file.
Use option -I with the name of a file to use that file as a customized prologue file (option includefile).
Supported options: -o, -v, -I, -W.
- MIB for SNMP. It generates a .bin file.
Supported options: -I, -o, -W.
- A compiled MIB for SNMP. It generates a .hrl file.
Supported options: -o, -v.
- Script file. It generates a boot file.
Use option -I to name directories to be searched for application files (equivalent to the path in the option list for systools:make_script/2).
Supported option: -o.
- ASN1 file. It creates an .erl, .hrl, and .asn1db file from an .asn1 file. Also compiles the .erl using the Erlang compiler unless option +noobj is specified.
Supported options: -I, -o, -b, -W.
- IC file. It runs the IDL compiler.
Supported options: -I, -o.
- The command for starting the emulator. Defaults to erl in the same directory as the erlc program itself, or, if it does not exist, erl in any of the directories specified in environment variable PATH.
SEE ALSO¶erl(1), compile(3erl), yecc(3erl), snmp(3erl)
|erts 8.2.1||Ericsson AB|