mrubyをダウンロードした。
mruby-1.2.0.tar.gz
展開
tar zxvf mruby-1.2.0.tar.gz
ビルド
cd mruby ruby minirake
mrubyでコンパイル
sample.cpp作る
#include <stdlib.h> #include <stdio.h> #include "mruby.h" #include "mruby/compile.h" int main() { auto mrb = mrb_open(); auto ai = mrb_gc_arena_save(mrb); mrb_load_string(mrb, "5.times.each {|i| p i * i }"); mrb_gc_arena_restore(mrb, ai); mrb_close(mrb); return 0; }
g++ -std=c++11 -Iinclude sample.cpp ../mruby/build/host/lib/libmruby.a
../mruby/build/host/lib/libmruby.a
がないと
Undefined symbols for architecture x86_64: "_mrb_close", referenced from: _main in sample-20efc4.o "_mrb_gc_arena_restore", referenced from: _main in sample-20efc4.o "_mrb_gc_arena_save", referenced from: _main in sample-20efc4.o "_mrb_load_string", referenced from: _main in sample-20efc4.o "_mrb_open", referenced from: _main in sample-20efc4.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)