在Ubuntu 14.04

时间:2016-04-01 12:49:12

标签: ruby-on-rails ruby ubuntu rubygems ubuntu-14.04

尝试在我的Ubuntu 14.04上安装ruby2d gem时出现以下错误

Building native extensions.  This could take a while...
ERROR:  Error installing ruby2d:
    ERROR: Failed to build gem native extension.

    /home/rishi/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20160401-21057-yotffi.rb extconf.rb
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling ruby2d.c
ruby2d.c: In function ‘render’:
ruby2d.c:133:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
   for (int i = 0; i < num_objects; ++i) {
   ^
ruby2d.c:133:3: note: use option -std=c99 or -std=gnu99 to compile your code
ruby2d.c:215:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
         struct image_data *data;
         ^
ruby2d.c:234:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
         struct text_data *data;
         ^
ruby2d.c: In function ‘ruby2d_show’:
ruby2d.c:253:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
   char *title = RSTRING_PTR(rb_iv_get(self, "@title"));
   ^
make: *** [ruby2d.o] Error 1

make failed, exit code 2

Gem files will remain installed in /home/rishi/.rvm/gems/ruby-2.2.1/gems/ruby2d-0.2.0 for inspection.
Results logged to /home/rishi/.rvm/gems/ruby-2.2.1/extensions/x86_64-linux/2.2.0/ruby2d-0.2.0/gem_make.out

如果有人能给我一些建议,那就太好了!

P.S。我已按照simple2d GitHub Page

上的所有步骤,在我的机器中成功安装了simple2d gem

提前致谢:)

1 个答案:

答案 0 :(得分:3)

借助these two个答案,您应该能够强制gcc切换到C99模式,方法是设置{{1}在宝石编译:

cflags

或者如果您使用bundler,请在运行gem install ruby2d -- --with-cflags=\"-std=c99\" 之前配置gem编译:

bundle install