#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