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

From: Agnes Schemelt (highflyer451 at hotmail.com)
Date: Tue Apr 15 16:44:23 EDT 2003

Hi, Paul:

Thanks for the reply. I arranged the directory structure as you suggested 
and it works now. But there was one final hitch I had to discover before 
getting it to work. And for those who might have to deal with it later on, 
I'll spell it out: it seems as though the module-loading mechanism is 
sensitive to file creation date.

If I had idmodule.ss as a dummy module for the extension idmodule.dll, the 
latter extension (as far as I can tell) must have a file date later than the 
former. Otherwise, when idmodule.ss is loaded, it complains that it cannot 
find the extension.

This means also that if I made any changes to idmodule.ss -- even as trivial 
as adding comments -- I have to 'touch' the extension to make it work.

This behavior seems odd. Is there a justification for it?

-- Agnes

>From: "Paul Steckler" <steck at ccs.neu.edu>

>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
>`scheme_finish_primitive_module'.
>
>That will create a .DLL that exports the required names.  You
>need to put that .DLL in the right place, which is
>
>   <path>/compiled/native/win32/i386/
>
>In <path>, you might want (need?) an imodule.ss file with the same
>exports.
>
>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
>


_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. 
http://join.msn.com/?page=features/junkmail



Posted on the users mailing list.