forked from mruby/mruby
-
Notifications
You must be signed in to change notification settings - Fork 1
Hello World
takahashim edited this page Feb 26, 2013
·
9 revisions
#include <stdlib.h>
#include <stdio.h>
/* Include the mruby header */
#include <mruby.h>
#include <mruby/compile.h>
int main(void)
{
mrb_state *mrb = mrb_open();
char code[] = "p 'hello world!'";
printf("Executing Ruby code from C!\n");
mrb_load_string(mrb, code);
return 0;
}
compile & link
$ gcc -Iinclude hello.c build/host/lib/libmruby.a -lm -o hello.out
execution
$ ./hello.out
Executing Ruby code from C!
"hello world!"
For more information on getting started, you can read this introduction blog post.