<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>Thank you for the reply, it is appreciated.<BR>
<BR>
I ran the below, per your recommendation. I found it only works if I also specify "--cgc". So, the command-line I ran was:<BR>
"C:\Program Files\MzScheme\mzc.exe" --cgc --cc test_scheme_embed.c<BR>
<BR>
yielding:<BR>mzc v371 [3m], Copyright (c) 2004-2007 PLT Scheme Inc.<BR>"test_scheme_embed.c":<BR> [output to ".\test_scheme_embed.obj"]<BR>
<BR>
followed by:<BR>
"C:\Program Files\MzScheme\mzc.exe" --ld test_scheme_embed.exe test_scheme_embed.obj<BR>
<BR>
yielding:<BR>mzc v371 [3m], Copyright (c) 2004-2007 PLT Scheme Inc.<BR>mzc: not a MzScheme extension filename (doesn't end with .dll): test_scheme_embed.exe<BR>
<BR>
I imagine there's something obvious I'm missing, but I haven't discovered what yet. Any advice appreciated.<BR>
<BR>
Thank you,<BR>
Matthew P.<BR><BR><BR><BR>
<HR id=stopSpelling>
<BR>
> Date: Fri, 30 Nov 2007 10:32:54 -0700<BR>> From: czhu@cs.utah.edu<BR>> To: mvfpadilla@hotmail.com<BR>> CC: plt-scheme@list.cs.brown.edu<BR>> Subject: Re: [plt-scheme] mzc embedding question<BR>> <BR>> Matthew Padilla wrote:<BR>> > Hello,<BR>> > <BR>> > I would like to compile a C++ program that embeds MzScheme, similar to <BR>> > the example given in the online documentation (see example at end of <BR>> > email). I would like to be able to pass it<BR>> > strings representing arbitrary Scheme programs, and have it evaluate them.<BR>> > <BR>> > I am running Microsoft's Visual C++ Express, on a Vista machine. <BR>> > <BR>> > Am I mistaken, or can I use mzc for this purpose? It seems as though <BR>> > mzc makes life easier by resolving linkage issues, etc. (e.g. to <BR>> > MzScheme libraries) but I'm not sure if this is only for<BR>> > extension writing. I've managed to produce .obj files via mzc... but <BR>> > not an .exe.<BR>> <BR>> Sure you can.<BR>> <BR>> mzc --cc yourfile.c<BR>> mzc --ld yourfile.exe yourfile.obj<BR>> <BR>> should work.<BR>> <BR>> Chongkai<BR>> <BR>> <BR>> > <BR>> > I have searched for examples but have found no good ones yet, so I <BR>> > apologize in advance if they have passed me by.<BR>> > <BR>> > Thank you,<BR>> > Matthew P.<BR>> > <BR>> > #include "scheme.h"<BR>> ><BR>> > int main(int argc, char *argv[])<BR>> > {<BR>> > Scheme_Env *e;<BR>> > Scheme_Object *curout;<BR>> > int i;<BR>> > mz_jmp_buf * volatile save, fresh;<BR>> ><BR>> > scheme_set_stack_base(NULL, 1); /* required for OS X, only */<BR>> ><BR>> > e = scheme_basic_env();<BR>> ><BR>> > curout = scheme_get_param(scheme_current_config(), <BR>> > MZCONFIG_OUTPUT_PORT);<BR>> ><BR>> > for (i = 1; i < argc; i++) {<BR>> > save = scheme_current_thread->error_buf;<BR>> > scheme_current_thread->error_buf = &fresh;<BR>> > if (scheme_setjmp(scheme_error_buf)) {<BR>> > scheme_current_thread->error_buf = save;<BR>> > return -1; /* There was an error */<BR>> > } else {<BR>> > Scheme_Object *v = scheme_eval_string(argv[i], e);<BR>> > scheme_display(v, curout);<BR>> > scheme_display(scheme_make_character('\n'), curout);<BR>> > /* read-eval-print loop, implicitly uses the initial Scheme_Env: */<BR>> > scheme_apply(scheme_builtin_value("read-eval-print-loop"), 0, NULL);<BR>> > scheme_current_thread->error_buf = save;<BR>> > }<BR>> > }<BR>> > return 0;<BR>> > }<BR>> ><BR>> > ------------------------------------------------------------------------<BR>> ><BR>> > _________________________________________________<BR>> > For list-related administrative tasks:<BR>> > http://list.cs.brown.edu/mailman/listinfo/plt-scheme<BR>> > <BR>> <BR><BR></body>
</html>