I've been trying to get mruby set up for use in C, but I've only had success compiling a simple "hello world" example. Other examples won't compile: when I try to compile https://github.com/mruby/mruby/blob/master/tools/mrbc/mrbc.c, I get this:
gcc -Iinclude hello.c libmruby_core.a libmruby.a -lm -o hello
hello.c: In function ‘parse_args’:
hello.c:119:24: error: ‘DUMP_DEBUG_INFO’ undeclared (first use in this function)
args->flags |= DUMP_DEBUG_INFO;
^
hello.c:119:24: note: each undeclared identifier is reported only once for each function it appears in
hello.c:122:23: error: ‘DUMP_ENDIAN_BIG’ undeclared (first use in this function)
args->flags = DUMP_ENDIAN_BIG | (args->flags & DUMP_DEBUG_INFO);
^
hello.c:125:23: error: ‘DUMP_ENDIAN_LIL’ undeclared (first use in this function)
args->flags = DUMP_ENDIAN_LIL | (args->flags & DUMP_DEBUG_INFO);
^
hello.c:154:57: error: ‘DUMP_ENDIAN_MASK’ undeclared (first use in this function)
if (args->verbose && args->initname && (args->flags & DUMP_ENDIAN_MASK) == 0) {
When I try to compile the 'more complex example' from http://matt.aimonetti.net/posts/2012/04/25/getting-started-with-mruby/, in the way they suggest (gcc -Iinclude hello.c lib/libmruby.a -lm -o hello.out
) (actually: in a similar way. I've tried both ways.) I get this:
gcc -Iinclude hello.c libmruby.a -lm -o hellohello.c: In function ‘main’:
hello.c:17:7: error: too few arguments to function ‘mrb_parse_string’
p = mrb_parse_string(mrb, code);
^
In file included from /home/neo/Projects/MrubyHs/mruby-1.1.0/include/mruby/irep.h:14:0,
from /home/neo/Projects/MrubyHs/mruby-1.1.0/include/mruby/proc.h:10,
from hello.c:6:
/home/neo/Projects/MrubyHs/mruby-1.1.0/include/mruby/compile.h:170:34: note: declared here
MRB_API struct mrb_parser_state* mrb_parse_string(mrb_state*,const char*,mrbc_context*);
^
hello.c:19:5: warning: assignment makes integer from pointer without a cast
n = mrb_generate_code(mrb, p);
^
hello.c:20:37: error: ‘mrb_state’ has no member named ‘irep’
mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_top_self(mrb));
^
Looks like I'm missing some file or something, but I'm not sure what. I'm using mruby 1.1.0. I have mruby-1.1.0/include which contains mrbconf.h, mruby.h, and a folder mruby in the gcc search path, and mruby-1.1.0/build/host/lib in LIBRARY_PATH (even though in my examples of what went wrong I just put them in the same folder as where I'm compiling).
Any idea what's wrong with my installation and/or how I'm compiling?