Subject: Re: [SWIPL] SWI and Xpce stand-alone program.

From: Jan Wielemaker <[email-masked]>
Date: Wed, 2 Jan 2002 15:58:11 +0100

Amir,

[Sorry for the late reaction; the mail-server had crashed]

> I am trying to make a stand alone program using SWI and XPCE
> 
> Following is my environment -
> 
> Development platform
> ---------------------
> 
> - Solaris 2.7
> - Installed Prolog (SWI / XPCE) 4.0.11 (path on machine is
>   /user/alsingh/SWI_XPCE/SWI-4.0.11)
> 
> Target platform
> ----------------
> - Solaris 2.7/2.8
> - no prolog installed
> 
> The standalone (that uses SWI as well as XPCE) that is generated
> works as expected on development platform, but does not work on
> target environment (program and error details attached at the end
> of mail)
> 
> Note
> =====
> The standalone generated (using only SWI and no reference of XPCE)
> works as expected on both development as well as target enviornment.
> 
> - Please provide help/pointers regarding what is missing !

Most likely pl2xpce.so; the XPCE foreign library.  There are two ways
to fix this problem.  One is to distribute the required .so files with
your package and make sure the file_search_path `foreign' is constructed
such that it can be found.  Windows has a little advantage that the
first place it looks for dynamic libraries is the directory holding
the executable.  This can't work for the general case in Unix, so
you have to find your own solution.  One is to use LD_LIBRARY_PATH
(see manual of ld for details).  There are many other possibilities
using application-specific environment variables, using the location
of the executable (as said not entirely fool-proof, but forgetting
about links and the possibility that the running file is already deleted
it works) available from current_prolog_flag(executable, Exe).

If you do not care about re-locating it gets easier.  You install
pl2xpce.so as /usr/local/lib/myapp/pl2xpce.so and add a rule to
the program stating

user:file_search_path(foreign, '/usr/local/lib/myapp').

Option two (especially for XPCE) is to create a version of SWI-Prolog
with a statically linked xpce library.  You do that from the xpce build
directory using the command "make pl-static", which creates a big file xpce,
containing both the Prolog kernel and xpce.  Copy the resulting file
alongside the pl executable in the installed hierarchy and, as pl itself,
link it from the public binary directory.  Now use this xpce to create
your saved-state.

	Success

		--- Jan