Skip to content
magewhopper edited this page Jul 5, 2012 · 10 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 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.

Clone this wiki locally