[plt-scheme] scheme inside c++

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Mar 18 07:46:13 EDT 2009

At Tue, 17 Mar 2009 21:12:10 -0400, e wrote:
> i tried to do this:
> http://www.godpatterns.com/article/embedding-scheme-in-c/
> [...]
> ./a.out #f::0: compile: unbound identifier (and no #%app syntax transformer
> is bound) at: + in: (+ 1 1)

Those instructions on that web page look right for version 3xx, but
things changed a little in in version 4.x.

Specifically, the `mzscheme' language is no longer built into the
MzScheme C library. Instead, you have to package up some bytecode to go
along with the C library, and the bytecode that you use depends on
which language --- `mzscheme', `scheme/base', `scheme', or something
else --- that you want to use.

Here's the documentation:


If you want to build on `scheme/base', then the main difference from
the http://www.godpatterns.com web page is that you need to run

 mzc --c-mods base.c ++lib scheme/base

to generate "base.c", and then add

    #include "base.c"


    /* after e = scheme_basic_env(): */

    /* Declare embedded modules in "base.c": */

to the embedding code.

The documentation now also recommends using scheme_main_setup() instead
of scheme_basic_env(), but I think you can stick with the latter if you

Posted on the users mailing list.