Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
erlc(1)				 User Commands			       erlc(1)

NAME
       erlc - Compiler

DESCRIPTION
       The  erlc program provides a common way to run all compilers in the Er-
       lang system. Depending on the extension of each input  file,  erlc  in-
       vokes  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	exten-
	      sion, for	example, .erl for Erlang source	code, or .yrl for Yecc
	      source code. Erlc	uses the extension to invoke the correct  com-
	      piler.

GENERALLY USEFUL FLAGS
       The following flags are supported:

	 -I _Directory_:
	   Instructs  the  compiler  to	search for include files in the	Direc-
	   tory. 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	speci-
	     fied last is searched first

	 -o _Directory_:
	   The directory where the compiler is to place	the output files.  De-
	   faults to the current working directory.

	 -D_Name_:
	   Defines a macro.

	 -D_Name_=_Value_:
	   Defines  a macro with the specified value. The value	can be any Er-
	   lang	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.

	 -W_Error_:
	   Makes all warnings into errors.

	 -W_Number_:
	   Sets	 warning level to Number. Defaults to 1. To turn off warnings,
	   use -W0.

	 -W:
	   Same	as -W1.	Default.

	 -v:
	   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 op-
	   tion	is ignored by compilers	that have a single output format.

	 -smp:
	   Compiles using the SMP emulator. This is mainly useful for  compil-
	   ing	native code, which must	be compiled with the same runtime sys-
	   tem that it is to be	run on.

	 -M:
	   Produces a Makefile rule to track header dependencies. The rule  is
	   sent	to stdout. No object file is produced.

	 -MMD:
	   Generate  dependencies  as  a  side-effect. The object file will be
	   produced as normal. This option overrides the option	-M.

	 -MF _Makefile_:
	   As option -M, except	that the Makefile is written to	 Makefile.  No
	   object file is produced.

	 -MD:
	   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.

	 -MP:
	   In conjunction with option -M or -MF, adds a	phony target for  each
	   dependency.

	 -MG:
	   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.

	 +_Term_:
	   A  flag  starting with a plus (+) rather than a hyphen is converted
	   to an Erlang	term and passed	unchanged to the compiler.  For	 exam-
	   ple,	 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 contain-
	   ing 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 rebuild-
       ing the OTP system:

	 -pa _Directory_:
	   Appends Directory to	the front of the code path in the invoked  Er-
	   lang	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:

	 .erl:
	   Erlang source code. It generates a .beam file.

	   Options -P, -E, and -S are equivalent to +'P', +'E',	and +'S',  ex-
	   cept	 that it is not	necessary to include the single	quotes to pro-
	   tect	them from the shell.

	   Supported options: -I, -o, -D, -v, -W, -b.

	 .S:
	   Erlang assembler source code. It generates a	.beam file.

	   Supported options: same as for .erl.

	 .core:
	   Erlang core source code. It generates a .beam file.

	   Supported options: same as for .erl.

	 .yrl:
	   Yecc	source code. It	generates an .erl file.

	   Use option -I with the name of a file to use	that file as a custom-
	   ized	prologue file (option includefile).

	   Supported options: -o, -v, -I, -W.

	 .mib:
	   MIB for SNMP. It generates a	.bin file.

	   Supported options: -I, -o, -W.

	 .bin:
	   A compiled MIB for SNMP. It generates a .hrl	file.

	   Supported options: -o, -v.

	 .rel:
	   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  sys-
	   tools:make_script/2).

	   Supported option: -o.

	 .asn1:
	   ASN1	file. It creates an .erl, .hrl,	and .asn1db file from an .asn1
	   file. Also compiles the .erl	using the Erlang compiler  unless  op-
	   tion	+noobj is specified.

	   Supported options: -I, -o, -b, -W.

	 .idl:
	   IC file. It runs the	IDL compiler.

	   Supported options: -I, -o.

ENVIRONMENT VARIABLES
	 ERLC_EMULATOR:
	   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(3), yecc(3), snmp(3)

Ericsson AB			   erts	10.3			       erlc(1)

NAME | DESCRIPTION | EXPORTS | GENERALLY USEFUL FLAGS | SPECIAL FLAGS | SUPPORTED COMPILERS | ENVIRONMENT VARIABLES | SEE ALSO

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=erlc&sektion=1&manpath=FreeBSD+12.1-RELEASE+and+Ports>

home | help