[plt-scheme] Using a C/C++ extension in a module

From: Paul Steckler (steck at ccs.neu.edu)
Date: Wed Apr 9 13:41:23 EDT 2003

> Hi. Thanks for your reply. This is one of the methods 
> suggested by others, 
> but it doesn't work. For testing, I used idmodule.c from 
> collects/mzscheme/examples. And I loaded it into a module "useme.ss", 
> defined as follows:
>      (module useme mzscheme
>          (load-extension "idmodule.dll")
>          (require idmodule)  ;; ERROR: says idmodule not bound!!
>          (provide identity)  ;; The only exposed function
>      )

It's a bit more complicated than my message might have suggested.

Inside your extension, you need to call `scheme_primitive_module'
to bind a name for the exported module.  Use `scheme_add_global'
to provide names from the module.  Then call 

That will create a .DLL that exports the required names.  You 
need to put that .DLL in the right place, which is 


In <path>, you might want (need?) an imodule.ss file with the same 

Then you just use 

  (require "idmodule.ss")

which will load the .DLL automagically.

For an example of this, see the MysterX distribution 
(http://www.plt-scheme.org/software/mysterx/).  There's 
an mxmain.dll file that exports a module, and a "dummy" 
mxmain.ss file with the same exports.

-- Paul

Posted on the users mailing list.