Prolog + C



Hello,

I am trying to link Prolog and C so I can call Prolog predicates from C code. Here's what I did and the problem that appear.

Prolog compiler is sicstus. Compiler is mingw with Code Blocks IDE.

Created a new project in Code Blocks.
Project - Build Options - Directories - "Add directory" - added the "include" directory of the prolog compiler directory.

Added the following code

#include <sicstus/sicstus.h>

int main () {

SP_pred_ref pred;
SP_qid goal;
SP_term_ref from, to;

printf ("Test");

}

Compiles ok.

The added the following code with an extra line taken from the examples

#include <sicstus/sicstus.h>

int main () {

SP_pred_ref pred;
SP_qid goal;
SP_term_ref from, to;

printf ("Test");

SP_initialize (0, NULL, NULL);

}

There are several linker errors, similar to:

..objs\main.o:main.c:(.text+0x38): undefined reference to `sp_GlobalSICStus'

Does anyone know howto do the setup?

Thanks.
.



Relevant Pages

  • Re: OT: Programming Careers
    ... Some of the earliest work in codifying laws as prolog code was done at ... The ability of the prolog compiler to compile it, ... which, for some reason lost to me, was impossible to codify. ...
    (rec.arts.sf.composition)
  • Re: Planner, micro-planner, etc.
    ... performance of Prolog, but we could have ended up with similar or even faster emulator-based Prolog implementations had we followed the DEC-10 implementation or the traditional Pascal machine. ... You may be convinced after comparing the latest version of B-Prolog with the major WAM-based systems. ... B-Prolog that is supported by the TOAM Jr ... a TOAM Jr machine code image of the TOAM Jr Prolog compiler that ...
    (comp.lang.prolog)
  • Re: Prolog Engine To Use With VB or C#?
    ... >> I would like to be able to use a Prolog engine from a VB or ... >There is also a version of Prolog compiler for .NET called P# ... so you would need to look at the sample code to ...
    (comp.lang.prolog)
  • Re: Prolog + C
    ... I am trying to link Prolog and C so I can call Prolog predicates from C code. ... Compiler is mingw with Code Blocks IDE. ... "include" directory of the prolog compiler directory. ...
    (comp.lang.prolog)
  • Re: N-Queens Benchmark
    ... Well, here's a C version of the Prolog code posted ... int valid{ ... POOL POOL POOL POOL POOL POOL POOL POOL ... SWI Prolog, which takes more than 4 seconds to find the first solution ...
    (comp.lang.prolog)