Executables embedding SWI-Prolog should be able to find the `home' directory of the development environment unless a self-contained saved-state has been added to the executable (see qsave_program/[1,2] and section 9.7).
If Prolog starts up, it will try to locate the development environment. To do so, it will try the following steps until one succeeds.
SWI_HOME_DIR
is defined and
points to an existing directory, use this.
SWIPL
is defined and points
to an existing directory, use this.
swipl
. If so, this file
contains the (relative) path to the home directory. If this directory
exists, use this. This is the normal mechanism used by the binary
distribution.
If all fails and there is no state attached to the executable or provided Windows module (see PL_initialise()), SWI-Prolog gives up. If a state is attached, the current working directory is used.
The file_search_path/2
alias swi
is set to point to the home directory located.