Subject: Re: Embedding troubles

From: Jan Wielemaker <[email-masked]>
Date: Wed, 2 Jun 1999 12:33:39 +0200

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