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
10       Erlang system. Depending on the extension  of  each  input  file,  erlc
11       invokes 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 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.
45           Defaults 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
52           Erlang 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         -W<Error>:
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
73           option is ignored by compilers that have a single output format.
74
75         -smp:
76           Compiles using the SMP emulator. This is mainly useful for  compil‐
77           ing  native code, which must be compiled with the same runtime sys‐
78           tem that it is to be run on.
79
80         -M:
81           Produces a Makefile rule to track header dependencies. The rule  is
82           sent to stdout. No object file is produced.
83
84         -MF <Makefile>:
85           As  option  -M, except that the Makefile is written to Makefile. No
86           object file is produced.
87
88         -MD:
89           Same as -M -MF <File>.Pbeam.
90
91         -MT <Target>:
92           In conjunction with option -M or -MF, changes the name of the  rule
93           emitted to Target.
94
95         -MQ <Target>:
96           As option -MT, except that characters special to make/1 are quoted.
97
98         -MP:
99           In  conjunction with option -M or -MF, adds a phony target for each
100           dependency.
101
102         -MG:
103           In conjunction with option -M or -MF, considers missing headers  as
104           generated files and adds them to the dependencies.
105
106         --:
107           Signals that no more options will follow. The rest of the arguments
108           is treated as filenames, even if they start with hyphens.
109
110         +<Term>:
111           A flag starting with a plus (+) rather than a hyphen  is  converted
112           to  an  Erlang term and passed unchanged to the compiler. For exam‐
113           ple, option export_all for the Erlang compiler can be specified  as
114           follows:
115
116         erlc +export_all file.erl
117
118           Depending  on  the platform, the value may need to be quoted if the
119           shell itself interprets certain characters. On Unix, terms contain‐
120           ing  tuples  and lists must be quoted. Terms containing spaces must
121           be quoted on all platforms.
122

SPECIAL FLAGS

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

SUPPORTED COMPILERS

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

ENVIRONMENT VARIABLES

197         ERLC_EMULATOR:
198           The command for starting the emulator. Defaults to erl in the  same
199           directory as the erlc program itself, or, if it does not exist, erl
200           in any of the directories specified in environment variable PATH.
201

SEE ALSO

203       erl(1), compile(3), yecc(3), snmp(3)
204
205
206
207Ericsson AB                      erts 9.3.3.10                         erlc(1)
Impressum