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

From: Jan Wielemaker <[email-masked]>
Date: Tue, 24 Jul 2001 10:40:06 +0200

> 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

On windows (actually on COFF based systems you need to link to libpl.dll.
Note that cygwin and MSVC don't mix too well.  Though a bit simplified,
you can only use cygwin if you recompile SWI-Prolog based on Cygwin.
Otherwise you need MSVC.  See README.cygwin in the sources.
	
	--- Jan