From jan@swi.psy.uva.nl Wed Jan  2 15:58:14 2002
Received: from gollem.swi.psy.uva.nl (root@gollem.swi.psy.uva.nl [145.18.152.30])
	by swi.psy.uva.nl (8.11.6/8.11.2) with ESMTP id g02EwET24974;
	Wed, 2 Jan 2002 15:58:14 +0100 (MET)
Received: (from jan@localhost)
	by gollem.swi.psy.uva.nl (8.11.3/8.11.3/SuSE Linux 8.11.1-0.5) id g02EwB101286;
	Wed, 2 Jan 2002 15:58:11 +0100
Date: Wed, 2 Jan 2002 15:58:11 +0100
Message-Id: <200201021458.g02EwB101286@gollem.swi.psy.uva.nl>
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Subject: Re: [SWIPL] SWI and Xpce stand-alone program.
To: mfamir@hss.hns.com, prolog@swi.psy.uva.nl
In-Reply-To: mfamir@hss.hns.com's message of Wed, 2 Jan 2002 15:20:05 +0530
Phone: +31 - 20 - 525 6121

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

