Did you know ... | Search Documentation: |
Predicate qsave_program/2 |
stand_alone
option, the resource is headed by the emulator,
a Unix shell script or nothing. Options is a list of
additional options:
prolog
starts the Prolog
toplevel and default
runs halt/0
if there are initialization goals and the prolog/0
toplevel otherwise.main
, the default toplevel is to enter the Prolog
interactive shell unless a goal has been specified using
goal(Callable)
.runtime
(default), read resources from the state and
disconnect the code loaded into the state from the original source. If
development
, save the predicates in their current state and
keep reading resources from their source (if present). See also
open_resource/3.true
(default), run autoload/0
first. If the class is
runtime
and autoload
is true
, the
state is supposed to be self contained and autoloading is disabled in
the restored state.save
(default) to save the current operator table or standard
to use the initial table of the emulator.true
, the emulator is the first part of the state. If
the emulator is started it tests whether a saved state is attached to
itself and load this state. Provided the application has all libraries
loaded, the resulting executable is completely independent from the
runtime environment or location where it was built. See also
section 2.11.1.4./usr/lib/swipl/lib/x86_64-linux/swipl
. To
create a saved state based on the public executable such that it can run
on multiple archirectures one can use e.g.
$ swipl -o myexe --emulator=$(which swipl) -c myload.pl
save
, include shared objects (DLLs) for the current
architecture into the saved state. See current_foreign_library/2,
and current_prolog_flag(arch, Arch). If the program strip is
available, this is first used to reduce the size of the shared object.
If a state is started, use_foreign_library/1
first tries to locate the foreign resource in the resource database.
When found it copies the content of the resource to a temporary file and
loads it. If possible (Unix), the temporary object is deleted
immediately after opening.246This
option is experimental and currently disabled by default. It will become
the default if it proves robust.247Creating
a temporary file is the most portable way to load a shared object from a
zip file but requires write access to the file system. Future versions
may provide shortcuts for specific platforms that bypass the file
system.
If Action is of the form arch(ListOfArches)
then the shared objects for the specified architectures are stored in
the saved state. On the command line, the list of architectures can be
passed as --foreign=<CommaSepArchesList>
.
In order to obtain the shared object file for the specified
architectures, qsave_program/2
calls a user defined hook:
qsave:arch_shlib(+Arch, +FileSpec, -SoPath)
. This hook
needs to unify SoPath
with the absolute path to the shared
object for the specified architecture. FileSpec
is of the
form foreign(Name)
.
At runtime, SWI-Prolog will try to load the shared library which is
compatible with the current architecture, obtained by calling
current_prolog_flag(arch, Arch)
. An architecture is
compatible if one of the two following conditions is true (tried in
order):
qsave:compat_arch(Arch1, Arch2)
hook
succeeds.This last one is useful when one wants to produce one shared object file that works for multiple architectures, usually compiling for the lowest common denominator of a certain CPU type. For example, it is common to compile for armv7 if even if the code will be running on newer arm CPUs. It is also useful to provide highly-optimized shared objects for particular architectures.
If Action is copy, the foreign extensions are copied to the installation location. This feature is currently only supported for Windows, where both DLLs required to run swipl.exe and DLLs loaded through extensions are are copied to the same directory as where the executable is saved. Required DLLs are found using win_process_modules/2. Thus, we can create an executable using e.g.,
swipl -o dist/myprog.exe --foreign=copy -c myprog.pl
The --foreign=copy
option is introduced in 9.3.6.
ignore
(default) or error
.
In the latter case creating the state is aborted with a message that
indicates the undefines predicates and from where they are called.true
(default false
), replace predicate
names with generated symbols to make the code harder to assess for
reverse engineering. See section
14.6.1.true
(default false
), report progress and
status, notably regarding auto loading.