ruby2d: build native failed with mruby 3.0.0
╰─ $ ruby2d build --native *.rb
build/app.c: In function ‘ruby2d_image_ext_load_image’:
build/app.c:3308:3: error: unknown type name ‘VALUE’
3308 | VALUE result = rb_ary_new2(3);
| ^~~~~
build/app.c:3308:18: warning: implicit declaration of function ‘rb_ary_new2’; did you mean ‘mrb_ary_new’? [-Wimplicit-function-declaration]
3308 | VALUE result = rb_ary_new2(3);
| ^~~~~~~~~~~
| mrb_ary_new
build/app.c:3313:3: warning: implicit declaration of function ‘rb_ary_push’; did you mean ‘mrb_ary_push’? [-Wimplicit-function-declaration]
3313 | rb_ary_push(result, r_data_wrap_struct(surface, surface));
| ^~~~~~~~~~~
| mrb_ary_push
In file included from build/app.c:2960:
build/app.c:3313:42: error: ‘surface_data_type’ undeclared (first use in this function); did you mean ‘music_data_type’?
3313 | rb_ary_push(result, r_data_wrap_struct(surface, surface));
| ^~~~~~~
build/app.c:3313:23: note: in expansion of macro ‘r_data_wrap_struct’
3313 | rb_ary_push(result, r_data_wrap_struct(surface, surface));
| ^~~~~~~~~~~~~~~~~~
build/app.c:3313:42: note: each undeclared identifier is reported only once for each function it appears in
3313 | rb_ary_push(result, r_data_wrap_struct(surface, surface));
| ^~~~~~~
build/app.c:3313:23: note: in expansion of macro ‘r_data_wrap_struct’
3313 | rb_ary_push(result, r_data_wrap_struct(surface, surface));
| ^~~~~~~~~~~~~~~~~~
build/app.c:3317:10: error: incompatible types when returning type ‘int’ but ‘mrb_value’ was expected
3317 | return result;
| ^~~~~~
build/app.c: In function ‘ruby2d_text_ext_load_text’:
build/app.c:3327:3: error: unknown type name ‘VALUE’
3327 | VALUE result = rb_ary_new2(3);
| ^~~~~
build/app.c:3330:43: error: macro "Data_Get_Struct" requires 4 arguments, but only 3 given
3330 | Data_Get_Struct(font, TTF_Font, ttf_font);
| ^
In file included from build/app.c:2960:
/usr/include/mruby/data.h:62: note: macro "Data_Get_Struct" defined here
62 | #define Data_Get_Struct(mrb,obj,type,sval) do {\
|
build/app.c:3330:3: error: ‘Data_Get_Struct’ undeclared (first use in this function)
3330 | Data_Get_Struct(font, TTF_Font, ttf_font);
| ^~~~~~~~~~~~~~~
build/app.c:3334:12: error: incompatible types when returning type ‘int’ but ‘mrb_value’ was expected
3334 | return result;
| ^~~~~~
In file included from build/app.c:2960:
build/app.c:3337:42: error: ‘surface_data_type’ undeclared (first use in this function); did you mean ‘music_data_type’?
3337 | rb_ary_push(result, r_data_wrap_struct(surface, surface));
| ^~~~~~~
build/app.c:3337:23: note: in expansion of macro ‘r_data_wrap_struct’
3337 | rb_ary_push(result, r_data_wrap_struct(surface, surface));
| ^~~~~~~~~~~~~~~~~~
build/app.c:3341:10: error: incompatible types when returning type ‘int’ but ‘mrb_value’ was expected
3341 | return result;
| ^~~~~~
build/app.c: In function ‘ruby2d_texture_ext_create’:
build/app.c:3350:52: error: macro "Data_Get_Struct" requires 4 arguments, but only 3 given
3350 | Data_Get_Struct(rubySurface, SDL_Surface, surface);
| ^
In file included from build/app.c:2960:
/usr/include/mruby/data.h:62: note: macro "Data_Get_Struct" defined here
62 | #define Data_Get_Struct(mrb,obj,type,sval) do {\
|
build/app.c:3350:3: error: ‘Data_Get_Struct’ undeclared (first use in this function)
3350 | Data_Get_Struct(rubySurface, SDL_Surface, surface);
| ^~~~~~~~~~~~~~~
In file included from build/app.c:2960:
build/app.c: In function ‘ruby2d_font_ext_load’:
build/app.c:3620:29: error: ‘font_data_type’ undeclared (first use in this function); did you mean ‘sound_data_type’?
3620 | return r_data_wrap_struct(font, font);
| ^~~~
build/app.c:3620:10: note: in expansion of macro ‘r_data_wrap_struct’
3620 | return r_data_wrap_struct(font, font);
| ^~~~~~~~~~~~~~~~~~
build/app.c: In function ‘main’:
build/app.c:4093:63: warning: passing argument 4 of ‘mrb_define_class_method’ from incompatible pointer type [-Wincompatible-pointer-types]
4093 | r_define_class_method(ruby2d_image_class, "ext_load_image", ruby2d_image_ext_load_image, r_args_req(1));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| mrb_value (*)(mrb_value, mrb_value)
build/app.c:3011:105: note: in definition of macro ‘r_define_class_method’
3011 | d(class, name, function, args) mrb_define_class_method(mrb, class, name, function, args)
| ^~~~~~~~
In file included from build/app.c:2955:
/usr/include/mruby.h:417:103: note: expected ‘mrb_func_t’ {aka ‘mrb_value (*)(struct mrb_state *, mrb_value)’} but argument is of type ‘mrb_value (*)(mrb_value, mrb_value)’
417 | s_method(mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t fun, mrb_aspec aspec);
| ~~~~~~~~~~~^~~
build/app.c:4099:61: warning: passing argument 4 of ‘mrb_define_class_method’ from incompatible pointer type [-Wincompatible-pointer-types]
4099 | r_define_class_method(ruby2d_text_class, "ext_load_text", ruby2d_text_ext_load_text, r_args_req(2));
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| |
| mrb_value (*)(mrb_value, mrb_value, mrb_value)
build/app.c:3011:105: note: in definition of macro ‘r_define_class_method’
3011 | d(class, name, function, args) mrb_define_class_method(mrb, class, name, function, args)
| ^~~~~~~~
In file included from build/app.c:2955:
/usr/include/mruby.h:417:103: note: expected ‘mrb_func_t’ {aka ‘mrb_value (*)(struct mrb_state *, mrb_value)’} but argument is of type ‘mrb_value (*)(mrb_value, mrb_value, mrb_value)’
417 | s_method(mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t fun, mrb_aspec aspec);
| ~~~~~~~~~~~^~~
build/app.c:4123:53: warning: passing argument 4 of ‘mrb_define_method’ from incompatible pointer type [-Wincompatible-pointer-types]
4123 | r_define_method(ruby2d_sound_class, "ext_length", ruby2d_sound_ext_length, r_args_none);
| ^~~~~~~~~~~~~~~~~~~~~~~
| |
| mrb_value (*)(mrb_value)
build/app.c:3010:93: note: in definition of macro ‘r_define_method’
3010 | _method(class, name, function, args) mrb_define_method(mrb, class, name, function, args)
| ^~~~~~~~
In file included from build/app.c:2955:
/usr/include/mruby.h:389:97: note: expected ‘mrb_func_t’ {aka ‘mrb_value (*)(struct mrb_state *, mrb_value)’} but argument is of type ‘mrb_value (*)(mrb_value)’
389 | e_method(mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t func, mrb_aspec aspec);
| ~~~~~~~~~~~^~~~
build/app.c:4153:53: warning: passing argument 4 of ‘mrb_define_method’ from incompatible pointer type [-Wincompatible-pointer-types]
4153 | r_define_method(ruby2d_music_class, "ext_length", ruby2d_music_ext_length, r_args_none);
| ^~~~~~~~~~~~~~~~~~~~~~~
| |
| mrb_value (*)(mrb_value)
build/app.c:3010:93: note: in definition of macro ‘r_define_method’
3010 | _method(class, name, function, args) mrb_define_method(mrb, class, name, function, args)
| ^~~~~~~~
In file included from build/app.c:2955:
/usr/include/mruby.h:389:97: note: expected ‘mrb_func_t’ {aka ‘mrb_value (*)(struct mrb_state *, mrb_value)’} but argument is of type ‘mrb_value (*)(mrb_value)’
389 | e_method(mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t func, mrb_aspec aspec);
| ~~~~~~~~~~~^~~~
build/app.c:4159:56: warning: passing argument 4 of ‘mrb_define_class_method’ from incompatible pointer type [-Wincompatible-pointer-types]
4159 | r_define_class_method(ruby2d_font_class, "ext_load", ruby2d_font_ext_load, r_args_req(3));
| ^~~~~~~~~~~~~~~~~~~~
| |
| mrb_value (*)(mrb_value, mrb_value, mrb_value, mrb_value)
build/app.c:3011:105: note: in definition of macro ‘r_define_class_method’
3011 | d(class, name, function, args) mrb_define_class_method(mrb, class, name, function, args)
| ^~~~~~~~
In file included from build/app.c:2955:
/usr/include/mruby.h:417:103: note: expected ‘mrb_func_t’ {aka ‘mrb_value (*)(struct mrb_state *, mrb_value)’} but argument is of type ‘mrb_value (*)(mrb_value, mrb_value, mrb_value, mrb_value)’
417 | s_method(mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t fun, mrb_aspec aspec);
| ~~~~~~~~~~~^~~
build/app.c:4165:53: warning: passing argument 4 of ‘mrb_define_method’ from incompatible pointer type [-Wincompatible-pointer-types]
4165 | r_define_method(ruby2d_texture_class, "ext_draw", ruby2d_texture_ext_draw, r_args_req(4));
| ^~~~~~~~~~~~~~~~~~~~~~~
| |
| mrb_value (*)(mrb_value, mrb_value, mrb_value, mrb_value, mrb_value)
build/app.c:3010:93: note: in definition of macro ‘r_define_method’
3010 | _method(class, name, function, args) mrb_define_method(mrb, class, name, function, args)
| ^~~~~~~~
In file included from build/app.c:2955:
/usr/include/mruby.h:389:97: note: expected ‘mrb_func_t’ {aka ‘mrb_value (*)(struct mrb_state *, mrb_value)’} but argument is of type ‘mrb_value (*)(mrb_value, mrb_value, mrb_value, mrb_value, mrb_value)’
389 | e_method(mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t func, mrb_aspec aspec);
| ~~~~~~~~~~~^~~~
build/app.c:4168:55: warning: passing argument 4 of ‘mrb_define_method’ from incompatible pointer type [-Wincompatible-pointer-types]
4168 | r_define_method(ruby2d_texture_class, "ext_create", ruby2d_texture_ext_create, r_args_req(3));
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| |
| mrb_value (*)(mrb_value, mrb_value, mrb_value, mrb_value)
build/app.c:3010:93: note: in definition of macro ‘r_define_method’
3010 | _method(class, name, function, args) mrb_define_method(mrb, class, name, function, args)
| ^~~~~~~~
In file included from build/app.c:2955:
/usr/include/mruby.h:389:97: note: expected ‘mrb_func_t’ {aka ‘mrb_value (*)(struct mrb_state *, mrb_value)’} but argument is of type ‘mrb_value (*)(mrb_value, mrb_value, mrb_value, mrb_value)’
389 | e_method(mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t func, mrb_aspec aspec);
| ~~~~~~~~~~~^~~~
build/app.c:4171:55: warning: passing argument 4 of ‘mrb_define_method’ from incompatible pointer type [-Wincompatible-pointer-types]
4171 | r_define_method(ruby2d_texture_class, "ext_delete", ruby2d_texture_ext_delete, r_args_req(1));
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| |
| mrb_value (*)(mrb_value, mrb_value)
build/app.c:3010:93: note: in definition of macro ‘r_define_method’
3010 | _method(class, name, function, args) mrb_define_method(mrb, class, name, function, args)
| ^~~~~~~~
In file included from build/app.c:2955:
/usr/include/mruby.h:389:97: note: expected ‘mrb_func_t’ {aka ‘mrb_value (*)(struct mrb_state *, mrb_value)’} but argument is of type ‘mrb_value (*)(mrb_value, mrb_value)’
389 | e_method(mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t func, mrb_aspec aspec);
| ~~~~~~~~~~~^~~~
Native app created at `build/app`
Following is my command.
# test.rb
require 'ruby2d'
show
ruby2d build --native test.rb
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 1
- Comments: 20
I managed to get it to build!!!
The app it builds doesn’t work, but we can look into that separately.
The way to get it to build was to include the numerous
.cfiles in the/extdirectory: -cc build/app.c #{@gem_dir}/ext/ruby2d/common.c #{@gem_dir}/ext/ruby2d/controllers.c #{@gem_dir}/ext/ruby2d/gl.c #{@gem_dir}/ext/ruby2d/gl2.c #{@gem_dir}/ext/ruby2d/gl3.c #{@gem_dir}/ext/ruby2d/font.c #{@gem_dir}/ext/ruby2d/image.c #{@gem_dir}/ext/ruby2d/input.c #{@gem_dir}/ext/ruby2d/music.c #{@gem_dir}/ext/ruby2d/shapes.c #{@gem_dir}/ext/ruby2d/sound.c #{@gem_dir}/ext/ruby2d/text.c #{@gem_dir}/ext/ruby2d/window.c -I#{@gem_dir}/ext/ruby2d -I#{@gem_dir}/assets/include -IC:/MSYS2/mingw64/include/ruby-3.0.0 -IC:/MSYS2/mingw64/include/ruby-3.0.0/x64-mingw32 -lmruby -lws2_32 -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lopengl32 -lglew32 -o build/appI’ll post my entire repo in another branch shortly.
This is a compiler issue with this code, I don’t think @matz would have any insight beyond what we’re able to do ourselves.
I’ve made some progress on this.
The core problem is the
ruby2d.cfile is mixingrubyfunctions andmrubyfunctions.For example,
VALUE result = rb_ary_new2(3);should bemrb_value result = mrb_ary_new(mrb);if you’re usingmruby.I have still a few errors so will update further if I fix them all.
BTW: in fact, we never reach this step because could not find
ruby2d.h, i have to do some hack to fix this.i create a PR, please check. #221