Subject: Re: [SWIPL] Calling SWI-Prolog from C

From: "Nissim Broudo" <[email-masked]>
Date: Tue, 24 Jul 2001 04:11:56 +0100

Dear All,

I managed to solve my own problem.  I compile with:

gcc -I"C:\Program Files\pl\include" -L"C:\Program Files\pl\bin" -lpl myprog.c

This was a hard-won discovery for a novice C programmer like myself !

Although my problem is soved, I would welcome any suggestions from you all.

Thanks,

Nissim Broudo

  ----- Original Message ----- 
  From: Nissim Broudo 
  To: [email-masked] 
  Sent: Monday, July 23, 2001 4:17 PM
  Subject: [SWIPL] Calling SWI-Prolog from C

  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