簡體   English   中英

為什么有些mruby示例無法編譯?

[英]Why won't some mruby examples compile?

我一直在嘗試將mruby設置為可在C中使用,但僅成功編譯了一個簡單的“ hello world”示例。 其他示例將無法編譯:當我嘗試編譯https://github.com/mruby/mruby/blob/master/tools/mrbc/mrbc.c時 ,我得到了:

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) {

當我嘗試以http://matt.aimonetti.net/posts/2012/04/25/getting-started-with-mruby/的方式編譯“更復雜的示例”時,它們的建議方式是( gcc -Iinclude hello.c lib/libmruby.a -lm -o hello.out )(實際上:以類似的方式。我已經嘗試過兩種方式。)我得到了:

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));
                                     ^

看起來我缺少一些文件或東西,但是我不確定是什么。 我正在使用mruby 1.1.0。 我有mruby-1.1.0 / include,它在gcc搜索路徑中包含mrbconf.h,mruby.h和一個文件夾mruby,並且在LIBRARY_PATH中包含mruby-1.1.0 / build / host / lib(即使在我的示例中出了什么問題,我只是將它們放在了我要編譯的文件夾中)。

知道我的安裝和/或編譯方式出了什么問題嗎?

您正在嘗試使用舊版本的mruby編譯新版本的mrbc.c 這些#define在1.1.0發布之后添加的。 如果我使用git repo中當前使用的mruby版本,則對我有用:

$ make
...
$ gcc -Iinclude build/host/lib/libmruby.a mrbc.c
$ ./a.out
./a.out: no program file given

至於第二個問題, mrb_parse_string改為接受mrb_context*作為第三個參數在2012年7月 ,所以你可能想看看更新的代碼,以使用新的API。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM