Subject: Re: Prolog calling C++

From: Jan Wielemaker <[email-masked]>
Date: Wed, 9 May 2001 09:56:37 +0200

On Wed, 09 May 2001, [email-masked] 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