From jan@swi.psy.uva.nl  Wed Jun  2 12:43:37 1999
Received: from gollem.swi.psy.uva.nl (jan@gollem.swi.psy.uva.nl [145.18.114.15])
	by swi.swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id MAA14098
	for <prolog@swi.psy.uva.nl>; Wed, 2 Jun 1999 12:43:37 +0200 (MET DST)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.8.8/8.8.8) id MAA18509;
	Wed, 2 Jun 1999 12:44:55 +0200
From: Jan Wielemaker <jan@swi.psy.uva.nl>
To: prolog@swi.psy.uva.nl, Luis Iraola Moreno <liraola@opera.dia.fi.upm.es>
Subject: Re: Embedding troubles
Date: Wed, 2 Jun 1999 12:33:39 +0200
X-Mailer: KMail [version 0.7.9]
Content-Type: text/plain
References: <Pine.SOL.3.95.990602091536.539D-100000@opera>
MIME-Version: 1.0
Message-Id: <99060212445500.15139@gollem>
Content-Transfer-Encoding: 8bit

On Wed, 02 Jun 1999, Luis Iraola Moreno wrote:

>I have been successfully embedding Prolog code within C++ applications
>using SWI 2.9.11 and VC++ 5.0 under Windows NT 4. My problem arises when
>trying to embed the same Prolog code using now SWI 3.2.7.
>
>After generating the corresponding QLF file with qsave_state/1 (using no
>options but specifying now the '.qlf' extension), and replacing the old
>(2.9.11) 'libpl.dll' with the new one, the call to PL_intialise() now
>stops the C++ application exiting with code 2.

How do you relate the state?  Basically, there are two options.  One is
to append the state to the main .exe file and the other is to pass 
-x <path-to-state> to PL_initialise().  Both are supposed to work.

Exit code 2 suggests the system trapped a fatal error.  If your
application is a GUI application, you may wish to tell the library such
by calling

	PL_action(PL_ACTION_GUIAPP, TRUE);

before PL_initialise().  That will make fatalError() create a Windows
message box rather sending the message to standard error which is not
connected to anything.

>The same code (Prolog and C++) works fine with version 2.9.11. I have
>tried to use the QLF file generated by 3.2.7 with the 2.9.11 libpl.dll and
>then I get the same exit code plus the explanation: 
>
>FATAL ERROR:
>		header script too long (> 100 lines)

The saved-state format has changed radically as of version 3.0.  In
general, the saved-state format should not be considered portable
between releases (and certainly not major releases).

>(I know that since 3.2.0 this message box does not appear, I suppose that
>is way I just have the exit code when I use 3.2.7 libpl.dll)

See the comment above.

>Have I skipped any relevant changes in the way qsave_program/1 and/or
>PL_initialise() work in the newer versions? Any help would be greatly
>appreciated.

At least in theory, the API for embedding should be compatible.

	Regards --- Jan

