Skip to content

Hello World

cremno edited this page · 10 revisions

Source Code

#include <stdio.h>
#include <mruby.h>
#include <mruby/compile.h>

int
main(void)
{
  mrb_state *mrb = mrb_open();
  if (!mrb) { /* handle error */ }
  puts("Executing Ruby code from C!");
  mrb_load_string(mrb, "p 'hello world!'");
  mrb_close(mrb);
  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.

Something went wrong with that request. Please try again.