From starred@tiscalinet.it Fri Aug  3 16:25:06 2001
Received: from smtp1.libero.it (smtp1.libero.it [193.70.192.51])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f73EP6b27786
	for <prolog@swi.psy.uva.nl>; Fri, 3 Aug 2001 16:25:06 +0200 (MET DST)
Received: from tiscalinet.it (151.24.145.69) by smtp1.libero.it (5.5.025)
        id 3AE980E7015B4723 for prolog@swi.psy.uva.nl; Fri, 3 Aug 2001 16:25:05 +0200
Message-ID: <3B6AB45A.9A555A76@tiscalinet.it>
Date: Fri, 03 Aug 2001 16:25:30 +0200
From: Armando Stellato <starred@tiscalinet.it>
X-Mailer: Mozilla 4.7 [en] (WinNT; I)
X-Accept-Language: en
MIME-Version: 1.0
To: SWI Mailing List <prolog@swi.psy.uva.nl>
Subject: Re: Problems with foreign libraries using dlls
References: <3B6AB42F.12B136FC@tiscalinet.it>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

OK, now i succeeded in creating a dll using Visual C++ (i inserted libpl.pl
into Project\settings\obect/library modules, don't know if it's correct but
now it compiles!). so...What problem now?
If i use the examples given in c in the manual, Prolog loads the library
i've created but when i ask for current_foreign_library/2 it gives me the
library without any exported function.
If I use the examples given with the CPP library (like test.cpp) it loads
the libraries and the functions, but the prolog doesn't write anything in
output: for example:
hello/0 returns (as it should be):  hello world, but only because it is
defined this way:
PlQuery q("write", PlTermv("hello world\n"));
  return q.next_solution();
if I write hello/1 (example: hello(world)): it says me only yes!!! it
ignores the cout in the c declaration:
cout << "name = " << A1.name() << ", arity = " << A1.arity() << endl;
return TRUE;

Well it's three days that i'm fighting against him...help!!

Armando Stellato wrote:

> Hi there,
> I've gotta some problems in creating DLL containing external predicates
> for prolog.
> Before creating my own predicates, I tried to use the examples in the
> manual.
> I'm using windows version of SWI-Prolog 'cause of porting problems from
> other works, but I'm not used to C compilers for Windows.
> I tried to use 3 different compilers (lcc, Borland 5.5 free compiler and
>
> Visual Basic), well, at least I succeeded in using one of them.
> This is the procedure i followed with lcc compiler:
>
> <created file "lowercase.c" from example>
>
> from shell: lcc -c lowercase.c
>
> <now lowercase.obj has been created>
>
> <
> created "lowercase.def" this way:
>
> EXPORTS
>     pl_lowercase
>
> >
>
> from shell: lcclnk -dll lowercase.obj libpl.lib lowercase.def
>
> <
> it was important to insert libpl.lib 'cause without this file,  it gave
> me
> the following errors:
>
> lowercase.obj .text: undefined reference to '_PL_get_atom_chars'
> lowercase.obj .text: undefined reference to '_PL_warning'
> lowercase.obj .text: undefined reference to '_PL_unify_atom_chars'
> lowercase.obj .text: undefined reference to '_PL_register_foreign'
> >
>
> so, once created the dll file, i imported it with
> load_foreign_library(lowercase), but i obtained only this bad message:
> it's impossible to find the entry point PL_Warning for the procedure in
> the dynamic link library CRTDLL.DLL.
>
> Is there someone out there that can solve my problem?
>
> If you want, you can explain me what to do with Visual C++, but i'd like
>
> a step-by-step procedure and a explanation of files to copy from (if
> there are) SWI-Prolog, the files i've yet copied from the prolog
> directory are: lib files form lib directory into the lib directory of
> the c-compilers and the header files into the c-compilers-headers
> directory.
>
> Excuse my poor english and the length of this mail, but i tried to be as
>
> clear as possible reporting ev'ry step i've done.
>
> Thank u in advance
>
> Armando Stellato

