This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Problem getting simple C-level module example to work.



I was trying to register and create a simple module from the C level,
and I can't get guile to use it.  I presume I'm just misunderstanding
how modules are supposed to work...

  $ gcc -Wall -o full-test full-test.c -lguile -lqthreads
  $ ./full-test 
  guile> (use-modules (foobar))
  ERROR: In procedure error in expression (error "no such module" module-name):
  ERROR: no such module (foobar)
  ABORT: (misc-error)

  Type "(backtrace)" to get more information.
  guile> (c-registered-modules)
  (("foobar" . 134514320))

Strace reveals guile is actually looking for a file containing the
module, even though all the information is statically linked 
from the C code.  Here's the very brief source:

  #include <guile/gh.h>

  static SCM
  foobar_func() {
    return(SCM_BOOL_T);
  }


  static void
  init_foobar() {
    gh_new_procedure("foobar_func", foobar_func, 0, 0, 0);
  }

  static void 
  main_helper(int argc, char *argv[]) {
    scm_register_module_xxx("foobar", init_foobar);
    gh_repl(argc, argv);
  }

  int
  main(int argc, char *argv[]) {
    gh_enter(argc, argv, main_helper);
    /* This will never return. */
    return(0);
  }

Any suggestions appreciated.

Thanks

-- 
Rob Browning <rlb@cs.utexas.edu> PGP=E80E0D04F521A094 532B97F5D64E3930