From lains@caramail.com  Tue Aug  8 15:26:49 2000
Received: from mail.caramail.com (mail.caramail.com [195.68.99.70])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id PAA15546
	for <prolog@swi.psy.uva.nl>; Tue, 8 Aug 2000 15:26:43 +0200 (MET DST)
Received: from caramail.com (www28.caramail.com [195.68.99.48])
	by mail.caramail.com (8.8.8/8.8.8) with SMTP id PAA12778
	for prolog@swi.psy.uva.nl; Tue, 8 Aug 2000 15:33:31 +0100 (WET DST)
Date: Tue, 8 Aug 2000 15:33:31 +0100 (WET DST)
Posted-Date: Tue, 8 Aug 2000 15:33:31 +0100 (WET DST)
From: Lionel Ains <lains@caramail.com>
To: prolog@swi.psy.uva.nl
Message-ID: <965744863017768@caramail.com>
X-Mailer: Caramail - www.caramail.com
Mime-Version: 1.0
Subject: Re: Linking SWI-Prolog with Link Grammar Parser v4.0
Content-Type: multipart/mixed; boundary="=_NextPart_Caramail_017768965744863_ID"

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

--=_NextPart_Caramail_017768965744863_ID
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi all,

finally, it works!
When I execute the program with plwin, everything is fine and the dll is loaded without any problem.
When I try to load the same program with plcon, it crashes after executing the entry point of the 
DLL and registering the foreign language library with the initialisation routine given through 
load_foreign_library/2 second parameter.

To get the working compiled DLL, I use the following compiling command with gcc under Cygwin:
gcc -I /cygdrive/c/Program\ Files/SWI-Prolog/include/ -I include/ -c src/lgp.c -o obj/lgp.o
Where /cygdrive/c/Program\ Files/SWI-Prolog/include/ is the posix path where SWI-Prolog's include 
directory is mounted.
include/ contains application-specific include files and src/lgp contains the code for the foreign 
language library (including a main() and the foreign initialisation routine).

Then, I can create the dll, from the object file lgp.o, linking it with cygwin1.dll (which is thus also 
necessary to run the foreign language library):
gcc -shared -o obj/lgp.dll obj/*.o /cygdrive/c/Program\ Files/SWI-prolog/bin/LIBPL.DLL
The path to LIBPL.DLL must of course be adapted to the posix path where LIBPL.DLL can be found 
(this is part of the SWI-Prolog native directory).

plcon still crashes when I try to load the foreign language interface by consulting the source file on the 
Prolog command line. However, if I use the following command-line for plcon:
C:\WINNT\Profiles\lains\Prolog>"C:\Program Files\SWI-Prolog\bin\plcon" -g "load_files(['prog.pl']), 
write('Program loaded'), nl, qsave_program('prog.exe', [goal=3Dgo, toplevel=3Dnone, stand_alone=3Dtrue]), 
write('Program successfully saved'), nl" -t halt.
The Prolog engine doesn't crash, I have the two "Program loaded" and "Program successfully saved" 
messages and finally I get an executable which runs properly!

There is maybe a bug in that story (plcon), but I managed to make it work this way at the end of the 
day.

Lionel

> -------Message d'origine-------
> De : Lionel Ains <lains@caramail.com>
> Date : 01/08/100 19:55:08
> 
> Hello
> 
> I have decided DLLs to link the foreign code to the Prolog engine.
> I'm using cygwin for Windows NT, and compiling my DLL with gcc under cygwin.
> Using the two lines given inside the manual, the prolog Engine crashes when executing 
> load_foreign_library/1. I have thus used another description I found about bulding a DLL with 
cygwin.
> Here are the commands I use (assuming that t.c is the foreign language source code):
> gcc -I/cygdrive/c/Program\ Files/SWI-Prolog/include -c t.c
> echo -e "EXPORTS\npl_lowercase\ninstall" > libt.def
> gcc -s -Wl,--base-file,libt.base -o libt.dll t.o /cygdrive/c/Program\ Files/SWI-Prolog/bin/Libpl.dll 
> -Wl,-e,_install
> dlltool --base-file libt.base --def libt.def --output-exp libt.exp --dllname libt.dll
> 
> The source file consists of the exmaple lowercase/2 predicate (chap 5.9), slightly modified to adapt 
to 
> cygwin.
> This gives me a library libt.dll
> When I try load_foreign_library(libt). under SWI-Prolog, I get immediately a Yes. without any output 
of 
> the debug messages included in install, which means that lowercase is not registered, and the 
failure 
> when calling lowercase/2 confirms it.
> 
> I've first tried the default compilation commands (figure 5.7 chap 5.9), it generates the dll but when I 
> call load_foreign_library(libt), I have the two debugging messages "Starting install function of 
library" 
> and "Exiting install function of library" and Prolog hangs.
> 
> Does someone have a preceding experience concerning cygwin, or would there be another free C 
> compiler that could do the job?
> 
> Thanks a lot,
> 
> Lionel 
______________________________________________________
Bo=EEte aux lettres - Caramail - http://www.caramail.com


--=_NextPart_Caramail_017768965744863_ID--

