From jan@swi.psy.uva.nl Wed May  9 10:10:41 2001
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.152.30])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f498Af303829;
	Wed, 9 May 2001 10:10:41 +0200 (MET DST)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) id f498AfI02364;
	Wed, 9 May 2001 10:10:41 +0200
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Organization: SWI, University of Amsterdam
To: ltcmdata@att.net, prolog@swi.psy.uva.nl
Subject: Re: Prolog calling C++
Date: Wed, 9 May 2001 09:56:37 +0200
X-Mailer: KMail [version 1.0.29.2]
Content-Type: text/plain
Cc: tsg@vax2.winona.msus.edu
References: <20010509072351.TPTE1648.mtiwmhc26.worldnet.att.net@webmail.worldnet.att.net>
In-Reply-To: <20010509072351.TPTE1648.mtiwmhc26.worldnet.att.net@webmail.worldnet.att.net>
MIME-Version: 1.0
Message-Id: <01050910104101.26886@gollem>
Content-Transfer-Encoding: 8bit

On Wed, 09 May 2001, ltcmdata@att.net wrote:
>
>Jan or Richard,

Richard is no developer.  Just a real Prolog expert.
This message wasn't accepted by the list, for which I'm
glad.  Please do not sent (especially binary) attachments
to the list!

>   I have tried without success to call a C++ funtion 
>from SWI-Prolog.  I have followed the example in the 
>help and have exported the install function and the 
>pl_say_hello function.  The functions seem to be 
>exported correctly.  When I double click on the attached 
>pl file in explorer to consult it, I get the error in 
>error.gif.  When I try another approach by 

Must be something rotten with the file (.pl) association.
Works fine here and on most systems I know.

>calling "load_foreign_library(interface).", I get a Yes 
>for an answer but when I try to call "pl_say_hello
>('hello').", I get ERROR:  Undefined procedure: 
>pl_say_hello/1.  The code for the dll can be found in 
>interface.cpp and interface.h.  The DLL is 
>interface.dll.  Am I doing something wrong?  Any help 
>would be greatly appreciated.

Because you register the file using PL_register_foreign("say_hello", 1,
pl_say_hello, 0).  The first argument is the name of the predicate. 
There *is* a predicate say_hello/1 that really works.

B.t.w. pl_say_hello() can (and should) simply be declared as
static foreign_t pl_say_hello() ...

B.t.w. Also see the real C++ interface.

	Cheers --- Jan

>Donald F. DeWalt

