			XPCE/C++ and XPCE/Prolog/C++
			============================

Auther:		Jan Wielemaker, SWI, University of Amsterdam

Modified:	March 27, 1997
		Tested in fixed for Solaris 2.5, gcc 2.7.2, Linux/ELF
Last Updated:	April 2, 1997
		Ported to Win32 platform using MSVC 4.2

This directory contains demos for the   XPCE/C++ interface.  These demos
have been developed to test  and   illustrate  the  functionality of the
interface; not to be pretty  looking   programs.   Please try the Prolog
demos to get an overview of the functionality of XPCE.

Documentation:
==============

You will find the documentation in PostScript at:

	ftp://swi.psy.uva.nl/pub/xpce/doc/CXX/pce2cxx.ps.gz (22 pages)

Or as HTML at

	http://swi.psy.uva.nl/projects/xpce/CXX/Title.html

Or as packaged set of HTML files at:

	ftp://swi.psy.uva.nl/pub/xpce/HTML/CXX.tgz


Preparation
===========

The Makefile is created by the   configuration  run from Makefile.in for
the current target platform.  Normally,  you   will  have  to change the
definition of PCEHOME in the Makefile to something like:

PCEHOME=/usr/local/lib/pl-2.8.1/xpce

You may wish to copy   $(PCEHOME)/lib/$(PCEARCH)/libXPCE.so*  to a place
where  your  system  is  looking   for    them,   such  as  /usr/lib  or
/usr/local/lib.


Compiling stand-alone executables
=================================

The file view.cxx defines a simple application that can be started as
	
	% ./view file ...

and creates an XPCE view object for   each  argument file. It dies after
the user closes the last view.

To compile it, run `make so'  in   the  ../../<arch> directory where you
have built XPCE. Now, do (use absolute paths   if  you want to start the
applications from another directory):

	% export LD_LIBRARY_PATH=../../lib/<arch>
	% export PCEHOME=../..
	% make view

Stand-alone executables need to be linked  to -lXPCE and -lXPCEmain. The
latter  provides  a  main()  wrapper  around  pceInitApplication()  that
initialises XPCE. The environment variable $PCEHOME   should  be set. It
you   donot   want    to    use     -lXPCEmain,    copy    and    modify
$PCEHOME/src/itf/main.cxx to suit your needs.


Loading XPCE/C++ defined classes in XPCE/(SWI-)Prolog
=====================================================

Compiling the demo
------------------

bnode.cxx defines the XPCE class b_node from C++.  Compile it using:

	% make bnode.so
	% xpce
	?- pce_load_cxx(bnode).
	?- manpce(b_node).

to verify the existence of the new class.

Problems and remarks
--------------------

    1) Linking. Global C++ constructors should work, and therefore, g++
       based shared objects need to be linked using:

	% g++ -shared file.o ... -o file.so -lXPCE

    2) SOLARIS: __builtin_new undefined
       Trying all the above on Solaris 2.5/g++ 2.7.2, all went well upto
       starting the manual, which actually starts querying the new
       class.  In this case the symbol __builtin_new was reported
       undefined.  This symbol is in -lgcc.  The only way I managed to
       get it to work is by relinking SWI-Prolog after adding
       `-u __builtin_new' to the LDFLAGS.

    3) LINUX: Applications cause a segmentation fault immediately.
       For one or another reason, you cannot link to the dynamic
       -lg++ library.  Don't ask me why.  See Makefile for details.
