This works if I explicitely define a module _and_ export the hug symbol.
(define-module (bug))
(export hug)
(use-modules (ice-9 format))
(define (hug x) (format #t "HUG ~a !\n" x))
#include <unistd.h>
#include <pthread.h>
#include <libguile.h>
static void *load_file_with_guile(void *filename)
{
scm_c_primitive_load((char *)filename);
return NULL;
}
static void *hug_me(void *str)
{
scm_c_eval_string(str);
}
static void *thread_hugme(void *dummy)
{
//scm_with_guile(load_file_with_guile, "bug.scm");
scm_with_guile(hug_me, "((@ (bug) hug) 2)");
return NULL;
}
int main(void) {
scm_with_guile(load_file_with_guile, "bug.scm");
scm_with_guile(hug_me, "((@ (bug) hug) 1)");
pthread_t thread;
pthread_create(&thread, NULL, thread_hugme, NULL);
pthread_join(thread, NULL);
return 0;
}