[plt-scheme] Accessing modules in a stand-alone executable

From: David Van Horn (dvanhorn at cs.uvm.edu)
Date: Sun May 11 17:09:09 EDT 2003

Ulf Leopold wrote:

> I have structured my application into collections. It
> also makes use of some of the standard collections,
> such as mzlib. Now I want to compile these collections
> to *native* code and link them together with the rest
> of the application to produce a fully stand-alone
> executable.
> 
> However, once a module has been compiled and linked
> with the application it can no longer be referred to
> the following way:
> 
>  (require (lib "mymodule.scm" "mycollection"))
> 
> Instead it must be referred to using its identifier:
> 
>  (require mymodule)
> 
> Since (when developing) I want to switch between
> having the modules compiled in and not, I would prefer
> to always keep the require statements on the first
> form. Another reason is that I don't want to modify,
> for example, the mzlib code. Is there a simple way to
> avoid this?

If you compile a module like this:

   cd mycollection
   mzc --auto-dir mymodule.ss
   MzScheme compiler (mzc) version 204, Copyright (c) 1996-2003 PLT
   "mymodule.ss":
     [output to "./compiled/native/i386-linux/mymodule.so"]

Then any program using mymodule needs only to state:

   (require (lib "mymodule.ss" "mycollection"))

The native code will be used unless the source code has been modified since
compilation time, in which case the source code will be used instead.

Does that help?

-d




Posted on the users mailing list.