Not able to access predicates exported by foreign library

13 views
Skip to first unread message

Manu Batura

unread,
Jan 26, 2016, 2:21:36 PM1/26/16
to SWI-Prolog
Hi All,

I am able to load a compiled foreign library but not able to see the predicates defined in the foreign library. Can someone help here.

Environment:
Platform: Macintosh
Operation System: Apple-Yosemite
SWI-Prolog: Pre-built available from swi-prolog.org (Multi-threaded, 64 bits, Version 7.2.3)
gcc: 4.2.1


Foreign Module source code:

hello.c
=====
#include <SWI-Prolog.h>

static foreign_t
pl_say_hello
(term_t to)
{
 PL_succeed
;
}

install_t
install
()
{
 PL_register_foreign
("say_hello", 1, pl_say_hello, 0);
}



Building the library:

gcc --shared -I/Applications/SWI-Prolog.app/Contents/swipl/include -o hello hello.c /Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin14.3.0/libswipl.a -lgmp -ltermcap


When I load the foreign library, it loads fine. However, I cannot see the say_hello/1 predicate. 


2 ?- load_foreign_library(foreign(hello)).

true.


3 ?- current_foreign_library(A, B).

A = foreign(hello),

B = []

A = foreign(readutil),

B = [read_util:read_line_to_codes(_G950, _G951, _G952), read_util:read_line_to_codes(_G941, _G942), read_util:read_stream_to_codes(_G931, _G932, _G933), read_util:read_stream_to_codes(_G922, _G923)].


Is the procedure I am using correct?


Regards,

Manu


Reply all
Reply to author
Forward
0 new messages