[plt-scheme] exe which uses C extension

From: Ron Stanonik (stanonik at Cogsci.ucsd.edu)
Date: Mon Feb 9 14:24:43 EST 2004

I'm trying to create an executable (mzc --exe) which uses a C extension.

If I start mzscheme and (load-extension "hello.so"), then I can (hello).
But if I compile the following, I get an error.
  ;arf.ss
  (module arf mzscheme
    (load-extension "hello.so")
    (hello))

  mzc --exe arf arf.ss
    unbound variable in module in: hello

I changed the C extension, so that it defines a module, hellomod, and
installed hellomod.so in compiled/native/i386-linux.
If I start mzscheme and (require (file "hellomod.ss")), then I can (hello).
But if I compile the following, I get an error.
  ;blap.ss
  (module blap mzscheme
    (require (file "hellomod.ss"))
    (hello))

  mzc --exe blap blap.ss
    cannot use extension file; "/home/stanonik/extension/compiled/native/i386-linux/hellomod.so"

Any suggestions?

Thanks,

Ron
stanonik at cogsci.ucsd.edu

=================
/*hello.c*/
#include "escheme.h"

Scheme_Object *
hello(int argc, Scheme_Object **argv)
{
  printf("bye\n");
  return scheme_true;
}

Scheme_Object *scheme_reload(Scheme_Env *env)
{
  scheme_add_global("hello",
    scheme_make_prim_w_arity(hello, "hello", 0, 0), env);

  return scheme_make_string("Hello");
}

Scheme_Object *scheme_initialize(Scheme_Env *env)
{ return scheme_reload(env); }

Scheme_Object *scheme_module_name()
{ return scheme_false; }

===============
/*hellomod.c*/
#include "escheme.h"

Scheme_Object *
hello(int argc, Scheme_Object **argv)
{
  printf("hello\n");
  return scheme_true;
}

Scheme_Object *scheme_reload(Scheme_Env *env)
{
  Scheme_Env *mod_env =
    scheme_primitive_module(scheme_intern_symbol("hellomod"), env);

  scheme_add_global("hello",
    scheme_make_prim_w_arity(hello, "hello", 0, 0), mod_env);

  scheme_finish_primitive_module(mod_env);

  return scheme_make_string("Hello");
}

Scheme_Object *scheme_initialize(Scheme_Env *env)
{ return scheme_reload(env); }

Scheme_Object *scheme_module_name()
{ return scheme_intern_symbol("hellomod"); }



Posted on the users mailing list.