Subject: [SWIPL] Problems with foreign libraries using dlls

From: Armando Stellato <[email-masked]>
Date: Fri, 03 Aug 2001 16:24:47 +0200

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