Subject: [SWIPL] Calling SWI-Prolog from C

From: "Nissim Broudo" <[email-masked]>
Date: Mon, 23 Jul 2001 16:17:24 +0100

My name is Nissim Broudo. I am working on a project that involves calling SWI-Prolog from C.  Unfortunately, I haven't been able to get this working and I would appreciate a pointer on where I am going wrong.  Here is my code:

#include <stdio.h>
#include <SWI-Prolog.h>

int main()
{ 

predicate_t p;
functor_t s2;
fid_t fid;
term_t goal;

goal = PL_new_term_ref();

}

The variable declarations work fine, but the compiler (gcc in the Cygwin package, Windows NT) complains:

Undefined reference to PL_new_term_ref
collect2: ld returned 1 exit status

I'm sure gcc is finding the SWI_Prolog header file b/c it finds the variable declarations and becuase when I try 

goal = PL_new_term_ref(1);

gcc complains:

too many arguments to function PL_new_term_ref

Please keep in mind, I am new to C programming and any pointers in the C programming area will be appreciated.  If you reply to the newsgroup, please copy me at [email-masked] since I haven't yet received confirmation that I am subscribed to the newsgroup.

Thanks in advance,

Nissim Broudo