[plt-scheme] Compiling modules that use homemade primitive modules

From: Ulf Leopold (ulfleopold at yahoo.com)
Date: Mon Feb 17 10:28:08 EST 2003

I have an application that needs to implement its own
main() function. The main() function obtains the
global MzScheme environment, defines a primitive
module named "prim", and then enters the Scheme code.
It looks something like this:

int main(...) {

    e = scheme_basic_env();

    mod =

    if (scheme_setjmp(scheme_error_buf)) {
        return 1;
    else {
        scheme_eval_string("(load \"main.scm\")", e);


In the Scheme code, I have implemented several modules
that are stored in a collection. These modules use the
module "prim" above. I.e:

(module testmodule mzscheme
  (require prim)

So far, everything works without any problems. But now
I would like to compile these modules into byte code
to improve loading speed. Preferably, I would even
like to compile them to C-code and link them with the
main application.

Compiling directly with mzc does not work since mzc
has no knowledge of "prim". I have also tried to
execute the compiler from within my own application
(where "prim" is available) as follows:

(current-command-line-arguments (vector
(require (lib "start.ss" "compiler"))

But I get the same output as for mzc:

MzScheme compiler (mzc) version 200, Copyright (c)
1996-2001 PLT
 [?,?]: Error: Error during elaboration: require:
unknown module: prim
Errors encountered.  Compilation aborted.

I'm wondering how I would go about compiling these

Thanks for any help,


Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day

Posted on the users mailing list.