Hello World - miura1729/mruby GitHub Wiki
#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.