Node:UNIX Runtime Systems on Target Machines, Previous:Interfacing to Cplusplus, Up:UNIX foreign language interface



Runtime Systems on Target Machines

This section describes how to distribute runtime systems on target machines, i.e. machines which do not have SICStus installed. An alternative approach to what is presented here is to package the whole application as an all-in-one executable; see All-in-one Executables.

In order to build a runtime system for distribution on a target machine, the option --moveable must be passed to spld. This option prevents spld from hardcoding any (absolute) paths into the executable.

Next, in order for SICStus to be able to locate all relevant files, the following directory structure should be used.

myapp.exe
sp-3.9.1/
+--- libsprt39.so
+--- sicstus-3.9.1/
     +--- bin/
     |    +--- sprt.sav
     +--- library/
          +--- <files from $SP_PATH/library>

If support for multiple SICStus instances is needed, then the run-times named e.g. libsprt39_instance_01_.so, need to be available as well, in the same place as libsprt39.so.

If SICStus is installed on the target machine, a symbolic link named sp-3.9.1 can be used, in which case it should point at the directory of the SICStus installation that contains the libsprt39.so (or equivalent).

myapp.exe is typically created by a call to spld:

% spld --main=user --moveable [...] -o ./myapp.exe

On most platforms, the above directory layout will enable the executable to find the SICStus run-time (libsprt39.so) as well as the boot file sprt.sav. In addition, application specific files, e.g. a .sav file, can be found using the automatically set environment variables SP_APP_DIR or SP_RT_DIR. On some platforms a wrapper script, generated by spld, is needed to ensure that the files are found.

On some platforms, the executable will not be able to locate sprt.sav unless the environment variable SP_PATH is set. If the example above is rooted in /home/joe, then SP_PATH should be set to /home/joe/lib/sicstus-3.9.1. This is not needed on platforms where SP_APP_DIR or SP_RT_DIR can be used, e.g. on Linux, Solaris or Win32 and most others.

Unless the --static option is passed to spld, it might also be necessary to set LD_LIBRARY_PATH (or equivalent) to /home/joe/lib (in the example above) in order for the dynamic linker to find libsprt39.so. If the --static option is used, this is not necessary. Setting LD_LIBRARY_PATH is not needed, nor recommended, on Linux and Solaris (and Win32).