1erlc(1)                          User Commands                         erlc(1)
2
3
4

NAME

6       erlc - Compiler
7

DESCRIPTION

9       The  erlc program provides a common way to run all compilers in the Er‐
10       lang system. Depending on the extension of each input  file,  erlc  in‐
11       vokes  the  appropriate compiler. Regardless of which compiler is used,
12       the same flags are used to provide parameters, such  as  include  paths
13       and output directory.
14
15       The  current  working  directory, ".", is not included in the code path
16       when running the compiler. This is to avoid loading Beam files from the
17       current  working  directory  that could potentially be in conflict with
18       the compiler or the Erlang/OTP system used by the compiler.
19

EXPORTS

21       erlc flags file1.ext file2.ext...
22
23              Compiles one or more files. The files must  include  the  exten‐
24              sion, for example, .erl for Erlang source code, or .yrl for Yecc
25              source code. Erlc uses the extension to invoke the correct  com‐
26              piler.
27

GENERALLY USEFUL FLAGS

29       The following flags are supported:
30
31         -I <Directory>:
32           Instructs  the  compiler  to search for include files in the Direc‐
33           tory. When encountering an -include or -include_lib directive,  the
34           compiler searches for header files in the following directories:
35
36           * ".", the current working directory of the file server
37
38           * The base name of the compiled file
39
40           * The  directories  specified using option -I; the directory speci‐
41             fied last is searched first
42
43         -o <Directory>:
44           The directory where the compiler is to place the output files.  De‐
45           faults to the current working directory.
46
47         -D<Name>:
48           Defines a macro.
49
50         -D<Name>=<Value>:
51           Defines  a macro with the specified value. The value can be any Er‐
52           lang term. Depending on the platform, the  value  may  need  to  be
53           quoted  if the shell itself interprets certain characters. On Unix,
54           terms containing tuples and lists must be quoted. Terms  containing
55           spaces must be quoted on all platforms.
56
57         -WError:
58           Makes all warnings into errors.
59
60         -W<Number>:
61           Sets  warning level to Number. Defaults to 1. To turn off warnings,
62           use -W0.
63
64         -W:
65           Same as -W1. Default.
66
67         -v:
68           Enables verbose output.
69
70         -b <Output_type>:
71           Specifies the type of output file. Output_type is the same  as  the
72           file extension of the output file, but without the period. This op‐
73           tion is ignored by compilers that have a single output format.
74
75         -no-server:
76           Do not use the compile server.
77
78         -server:
79           Use the compile server.
80
81         -M:
82           Produces a Makefile rule to track header dependencies. The rule  is
83           sent to stdout. No object file is produced.
84
85         -MMD:
86           Generate  dependencies  as  a  side-effect. The object file will be
87           produced as normal. This option overrides the option -M.
88
89         -MF <Makefile>:
90           As option -M, except that the Makefile is written to  Makefile.  No
91           object file is produced.
92
93         -MD:
94           Same as -M -MF <File>.Pbeam.
95
96         -MT <Target>:
97           In  conjunction with option -M or -MF, changes the name of the rule
98           emitted to Target.
99
100         -MQ <Target>:
101           As option -MT, except that characters special to make/1 are quoted.
102
103         -MP:
104           In conjunction with option -M or -MF, adds a phony target for  each
105           dependency.
106
107         -MG:
108           In  conjunction with option -M or -MF, considers missing headers as
109           generated files and adds them to the dependencies.
110
111         --:
112           Signals that no more options will follow. The rest of the arguments
113           is treated as filenames, even if they start with hyphens.
114
115         +<Term>:
116           A  flag  starting with a plus (+) rather than a hyphen is converted
117           to an Erlang term and passed unchanged to the compiler.  For  exam‐
118           ple,  option export_all for the Erlang compiler can be specified as
119           follows:
120
121         erlc +export_all file.erl
122
123           Depending on the platform, the value may need to be quoted  if  the
124           shell itself interprets certain characters. On Unix, terms contain‐
125           ing tuples and lists must be quoted. Terms containing  spaces  must
126           be quoted on all platforms.
127

SPECIAL FLAGS

129       The  following flags are useful in special situations, such as rebuild‐
130       ing the OTP system:
131
132         -pa <Directory>:
133           Appends Directory to the front of the code path in the invoked  Er‐
134           lang emulator. This can be used to invoke another compiler than the
135           default one.
136
137         -pz <Directory>:
138           Appends Directory to the code path in the invoked Erlang emulator.
139

SUPPORTED COMPILERS

141       The following compilers are supported:
142
143         .erl:
144           Erlang source code. It generates a .beam file.
145
146           Options -P, -E, and -S are equivalent to +'P', +'E', and +'S',  ex‐
147           cept  that it is not necessary to include the single quotes to pro‐
148           tect them from the shell.
149
150           Supported options: -I, -o, -D, -v, -W, -b.
151
152         .S:
153           Erlang assembler source code. It generates a .beam file.
154
155           Supported options: same as for .erl.
156
157         .core:
158           Erlang core source code. It generates a .beam file.
159
160           Supported options: same as for .erl.
161
162         .yrl:
163           Yecc source code. It generates an .erl file.
164
165           Use option -I with the name of a file to use that file as a custom‐
166           ized prologue file (option includefile).
167
168           Supported options: -o, -v, -I, -W.
169
170         .mib:
171           MIB for SNMP. It generates a .bin file.
172
173           Supported options: -I, -o, -W.
174
175         .bin:
176           A compiled MIB for SNMP. It generates a .hrl file.
177
178           Supported options: -o, -v.
179
180         .rel:
181           Script file. It generates a boot file.
182
183           Use  option  -I  to name directories to be searched for application
184           files  (equivalent  to  the  path  in  the  option  list  for  sys‐
185           tools:make_script/2).
186
187           Supported option: -o.
188
189         .asn1:
190           ASN1 file. It creates an .erl, .hrl, and .asn1db file from an .asn1
191           file. Also compiles the .erl using the Erlang compiler  unless  op‐
192           tion +noobj is specified.
193
194           Supported options: -I, -o, -b, -W.
195
196         .idl:
197           IC file. It runs the IDL compiler.
198
199           Supported options: -I, -o.
200

COMPILE SERVER

202       The  compile  server  can  be used to potentially speed up the build of
203       multi-file projects by avoiding to start an Erlang system for each file
204       to compile. Whether it will speed up the build depends on the nature of
205       the project and the build machine.
206
207       By default, the compile server is not used. It can be enabled by giving
208       erlc  the  option  -server  or  by  setting  the  environment  variable
209       ERLC_USE_SERVER to yes or true.
210
211       When the compile server is enabled, erlc  will  automatically  use  the
212       server  if  it  is  started  and  start  the  server if has not already
213       started. The server will terminate itself when it  has  been  idle  for
214       some number of seconds.
215
216       erlc  and the compile server communicate using the Erlang distribution.
217       The compile server is started as a hidden node, with a  name  that  in‐
218       cludes  the  current  user. Thus, each user on a computer has their own
219       compile server.
220
221       Using the compile server does not always speed up  the  build,  as  the
222       compile  server sometimes must be restarted to ensure correctness. Here
223       are some examples of situtations that force a restart:
224
225         * erlc wants to use a different version of Erlang  than  the  compile
226           server is using.
227
228         * erlc wants to use different options for erl than the compile server
229           was started with. (A change to code path using the option -pa could
230           cause different parse transforms to be loaded. To be safe, the com‐
231           pile server will be restarted when any erl option is changed.)
232
233         * If the current working directory for erlc  is  different  from  the
234           working  directory  active when the compile server was started, and
235           if the compile server has active jobs, it will be restarted as soon
236           as  those  jobs have finished. (Build systems that build files ran‐
237           domly across multiple directories in  parallel  will  probably  not
238           benefit from the compile server.)
239

ENVIRONMENT VARIABLES

241         ERLC_EMULATOR:
242           The  command for starting the emulator. Defaults to erl in the same
243           directory as the erlc program itself, or, if it does not exist, erl
244           in any of the directories specified in environment variable PATH.
245
246         ERLC_USE_SERVER:
247           Allowed values are yes or true to use the compile server, and no or
248           false to not use the compile server. If  other  values  are  given,
249           erlc will print a warning message and continue.
250
251         ERLC_SERVER_ID:
252           Tells erlc to identify the compile server by the given name, allow‐
253           ing a single user to run  multiple  unrelated  builds  in  parallel
254           without  them  affecting each other, which can be useful for shared
255           build machines and the like. The name must be alphanumeric, and  it
256           defaults to being empty.
257

SEE ALSO

259       erl(1), compile(3), yecc(3), snmp(3)
260
261
262
263Ericsson AB                      erts 12.3.2.1                         erlc(1)
Impressum