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         -MMD:
85           Generate  dependencies  as  a  side-effect. The object file will be
86           produced as normal. This option overrides the option -M.
87
88         -MF <Makefile>:
89           As option -M, except that the Makefile is written to  Makefile.  No
90           object file is produced.
91
92         -MD:
93           Same as -M -MF <File>.Pbeam.
94
95         -MT <Target>:
96           In  conjunction with option -M or -MF, changes the name of the rule
97           emitted to Target.
98
99         -MQ <Target>:
100           As option -MT, except that characters special to make/1 are quoted.
101
102         -MP:
103           In conjunction with option -M or -MF, adds a phony target for  each
104           dependency.
105
106         -MG:
107           In  conjunction with option -M or -MF, considers missing headers as
108           generated files and adds them to the dependencies.
109
110         --:
111           Signals that no more options will follow. The rest of the arguments
112           is treated as filenames, even if they start with hyphens.
113
114         +<Term>:
115           A  flag  starting with a plus (+) rather than a hyphen is converted
116           to an Erlang term and passed unchanged to the compiler.  For  exam‐
117           ple,  option export_all for the Erlang compiler can be specified as
118           follows:
119
120         erlc +export_all file.erl
121
122           Depending on the platform, the value may need to be quoted  if  the
123           shell itself interprets certain characters. On Unix, terms contain‐
124           ing tuples and lists must be quoted. Terms containing  spaces  must
125           be quoted on all platforms.
126

SPECIAL FLAGS

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

SUPPORTED COMPILERS

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

ENVIRONMENT VARIABLES

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

SEE ALSO

207       erl(1), compile(3), yecc(3), snmp(3)
208
209
210
211Ericsson AB                      erts 10.3.5.2                         erlc(1)
Impressum