This chapter describes the features of SWI-Prolog for delivering applications that can run without the development version of the system installed.
A SWI-Prolog built application consists of at least two parts: the emulator and the compiled application. The latter is in the same format as a SWI-Prolog boot-file and SWI-Prolog pre-compiled (QLF) file. This format is fast loadable and abstracted just far enough to be machine independent. This implies an application delivered in binary format can run on any computer for which an emulator is available without modification.
Key | Option | Type | Description |
local | -L | K-bytes | Size (Limit) of local stack |
global | -G | K-bytes | Size (Limit) of global stack |
trail | -T | K-bytes | Size (Limit) of trail stack |
argument | -A | K-bytes | Size (Limit) of argument stack |
goal | -g | atom | Initialisation goal |
toplevel | -t | atom | Prolog toplevel goal |
init_file | -f | atom | Personal initialisation file |
autoload | bool | If true, runautoload/0first | |
map | atom | File containing info on dump | |
op | save/standard | Save operator declarations? | |
stand_alone | bool | Include the emulator in the state |
The /bin/sh script contains the following data:
user
or the module
user
contains a different definition as the one imported in
the target module.'
Before writing the data to file, qsave_program/2 will run autoload/0 to all required autoloading the system can discover. See autoload/0.
Provided the application does not require any of the Prolog libraries to be loaded at runtime, the only file from the SWI-Prolog development environment required is the emulator itself. The emulator may be built in two flavours. The default is the development emulator. The runtime emulator is similar, but lacks the tracer. The stand-alone program chpl(1) may be used to change the default path to the emulator.
If the option stand_alone(on)
is present, the emulator
is prepended for the state. If the emulator is started and no state is
specified using the -x flag, it will test whether a
boot-file (state) is attached to the emulator itself and load this
state. Provided the application has all libraries loaded, the resulting
file may be started anywhere.
qsave_program(File, [])
.
This predicate is used by qsave_program/[1,2] to ensure the saved state will not depend on one of the libraries. The predicate autoload/0 will find all direct references to predicates. It does not find predicates referenced via meta-predicates. The predicate log/2 is defined in the library(quintus) to provide a quintus compatible means to compute the natural logarithm of a number. The following program will behave correctly if its state is executed in an environment where the library(quintus) is not available:
However, the following implementation refers to log/2 through the meta-predicate maplist/3. Autoload will not be able to find the reference. This problem may be fixed either by loading the module libtary(quintus) explicitly or use require/1 to tell the system that the predicate log/2 is required by this module.