[Up] [Contents] [Index] [Summary]

2.7 Compilation

Collections of SWI-Prolog source files can be compiled into an intermediate code file. An intermediate code file is a data file from which SWI-Prolog can be started. The command to compile a bundle of source files is:

pl [options] [-o output] -c file ...

The individual source files may include other files using the standard list notation, consult/1, ensure_loaded/1 and use_module/[1,2]. When the -o file option is omitted a file named a.out is created that holds the intermediate code file.

Intermediate code files start with the BSD Unix magic code #! and are executable. This implies they can be started as a command:

% pl -o my_program -c ... ... % my_program [options]

Alternatively, my_program can be started with

% pl -x my_program [options]

The following restrictions apply to source files that are to be compiled with `-c':

Directives are executed both when compiling the program and when loading the intermediate code file.