[plt-scheme] mzc embedding question

From: Matthew Padilla (mvfpadilla at hotmail.com)
Date: Fri Nov 30 13:00:44 EST 2007

Thank you for the reply, it is appreciated.
 
I ran the below, per your recommendation.  I found it only works if I also specify "--cgc".  So, the command-line I ran was:
"C:\Program Files\MzScheme\mzc.exe" --cgc --cc test_scheme_embed.c
 
yielding:mzc v371 [3m], Copyright (c) 2004-2007 PLT Scheme Inc."test_scheme_embed.c": [output to ".\test_scheme_embed.obj"]
 
followed by:
"C:\Program Files\MzScheme\mzc.exe" --ld test_scheme_embed.exe test_scheme_embed.obj
 
yielding:mzc v371 [3m], Copyright (c) 2004-2007 PLT Scheme Inc.mzc: not a MzScheme extension filename (doesn't end with .dll): test_scheme_embed.exe
 
I imagine there's something obvious I'm missing, but I haven't discovered what yet.  Any advice appreciated.
 
Thank you,
Matthew P.



> Date: Fri, 30 Nov 2007 10:32:54 -0700> From: czhu at cs.utah.edu> To: mvfpadilla at hotmail.com> CC: plt-scheme at list.cs.brown.edu> Subject: Re: [plt-scheme] mzc embedding question> > Matthew Padilla wrote:> > Hello,> > > > I would like to compile a C++ program that embeds MzScheme, similar to > > the example given in the online documentation (see example at end of > > email). I would like to be able to pass it> > strings representing arbitrary Scheme programs, and have it evaluate them.> > > > I am running Microsoft's Visual C++ Express, on a Vista machine. > > > > Am I mistaken, or can I use mzc for this purpose? It seems as though > > mzc makes life easier by resolving linkage issues, etc. (e.g. to > > MzScheme libraries) but I'm not sure if this is only for> > extension writing. I've managed to produce .obj files via mzc... but > > not an .exe.> > Sure you can.> > mzc --cc yourfile.c> mzc --ld yourfile.exe yourfile.obj> > should work.> > Chongkai> > > > > > I have searched for examples but have found no good ones yet, so I > > apologize in advance if they have passed me by.> > > > Thank you,> > Matthew P.> > > > #include "scheme.h"> >> > int main(int argc, char *argv[])> > {> > Scheme_Env *e;> > Scheme_Object *curout;> > int i;> > mz_jmp_buf * volatile save, fresh;> >> > scheme_set_stack_base(NULL, 1); /* required for OS X, only */> >> > e = scheme_basic_env();> >> > curout = scheme_get_param(scheme_current_config(), > > MZCONFIG_OUTPUT_PORT);> >> > 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 = scheme_eval_string(argv[i], e);> > scheme_display(v, curout);> > scheme_display(scheme_make_character('\n'), curout);> > /* read-eval-print loop, implicitly uses the initial Scheme_Env: */> > scheme_apply(scheme_builtin_value("read-eval-print-loop"), 0, NULL);> > scheme_current_thread->error_buf = save;> > }> > }> > return 0;> > }> >> > ------------------------------------------------------------------------> >> > _________________________________________________> > For list-related administrative tasks:> > http://list.cs.brown.edu/mailman/listinfo/plt-scheme> > > 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20071130/3242a049/attachment.html>

Posted on the users mailing list.