[plt-scheme] Embedding MzScheme on Mac OS X

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Sun Jul 12 17:44:30 EDT 2009

Hi All,

I need help figuring out the correct compiler switched for embedding
mzscheme in
a C application on Mac OS 10.5.

I succeeded in compiling the example code in


but running the result was disappointing.

Hopefully I have missed something obvious - but what?

The mysterios ./pltcur is a symbolic link to /Applications/PLT\ Scheme\
Full\ v4.2.0.2/ .

jasmacair:mzc-experiment jensaxelsoegaard$ /Applications/PLT\ Scheme\ Full\
v4.2.0.2/bin/mzc --c-mods modules.c ++lib scheme/base

jas: mzc-experiment jensaxelsoegaard$ gcc -L./pltcur/lib/
 -I./pltcur/include/ -F./pltcur/lib/ -framework PLT_MzScheme -lmzscheme
-lmzgc   embedded.c

jas: mzc-experiment jensaxelsoegaard$ export
DYLD_FRAMEWORK_PATH=/Applications/PLT\ Scheme\ Full\ v4.2.0.2/lib/

jas: mzc-experiment jensaxelsoegaard$ ./a.out "1"
Seg fault (internal error) at 0x87
Bus error

jas: mzc-experiment jensaxelsoegaard$ ./a.out 1
Seg fault (internal error) at 0x87
Bus error

jas: mzc-experiment jensaxelsoegaard$ cat embedded.c
#include "scheme.h"
#include "modules.c"

static int run(Scheme_Env *e, int argc, char *argv[])
  Scheme_Object *curout;
  int i;
  mz_jmp_buf * volatile save, fresh;

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


  curout = scheme_get_param(scheme_current_config(),

  for (i = 1; i < argc; i++) {
    save = scheme_current_thread->error_buf;
    scheme_current_thread->error_buf = &fresh;
    if (scheme_setjmp(scheme_error_buf)) {
      scheme_current_thread->error_buf = save;
      return -1; /* There was an error */
    } else {
      Scheme_Object *v, *a[2];
      v = scheme_eval_string(argv[i], e);
      scheme_display(v, curout);
      scheme_display(scheme_make_char('\n'), curout);
      /* read-eval-print loop, uses initial Scheme_Env: */
      a[0] = scheme_intern_symbol("scheme/base");
      a[1] = scheme_intern_symbol("read-eval-print-loop");
      scheme_apply(scheme_dynamic_require(2, a), 0, NULL);
      scheme_current_thread->error_buf = save;
  return 0;

int main(int argc, char *argv[])
  return scheme_main_setup(1, run, argc, argv);

Jens Axel Søgaard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090712/03213a59/attachment.html>

Posted on the users mailing list.