table of contents
erlc(1) | User Commands | erlc(1) |
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 is 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.
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>
-o <Directory>
-D<Name>
-D<Name>=<Value>
-WError
-W<Number>
-W
-v
-b <Output_type>
-no-server
-server
-enable-feature <Feature>
-disable-feature <feature>
-list-features
-describe-feature <feature>
-M
-MMD
-MF <Makefile>
-MD
-MT <Target>
-MQ <Target>
-MP
-MG
--
+<Term>
-
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>
-pz <Directory>
Supported Compilers¶
The following compilers are supported:
.erl
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.
.S
Supported options: same as for .erl.
.core
Supported options: same as for .erl.
.yrl
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
Supported options: -I, -o, -W.
.bin
Supported options: -o, -v.
.rel
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
Supported options: -I, -o, -b, -W.
.idl
Supported options: -I, -o.
Compile Server¶
The compile server can be used to potentially speed up the build of multi-file projects by avoiding to start an Erlang system for each file to compile. Whether it will speed up the build depends on the nature of the project and the build machine.
By default, the compile server is not used. It can be enabled by giving erlc the option -server or by setting the environment variable ERLC_USE_SERVER to yes or true.
When the compile server is enabled, erlc will automatically use the server if it is started and start the server if has not already started. The server will terminate itself when it has been idle for some number of seconds.
erlc and the compile server communicate using the Erlang distribution. The compile server is started as a hidden node, with a name that includes the current user. Thus, each user on a computer has their own compile server.
Using the compile server does not always speed up the build, as the compile server sometimes must be restarted to ensure correctness. Here are some examples of situations that force a restart:
Environment Variables¶
ERLC_EMULATOR
ERLC_USE_SERVER
ERLC_SERVER_ID
See Also¶
erl(1), compile, yecc, snmp
erts 15.1.3 | Ericsson AB |