简体   繁体   中英

Error Installing gem `ruby2d` on Ubuntu 14.04

I am getting following error while try to install ruby2d gem on my Ubuntu 14.04

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

It would be great if anyone can give me some suggestions!

PS I had successfully installed simple2d gem in my machine by follow all the steps given over simple2d GitHub Page

Thanks in advance :)

With the help of these two answers, you should be able to force gcc to switch to the C99 mode by setting the cflags upon gem compilation:

gem install ruby2d -- --with-cflags=\"-std=c99\"

or if you use bundler, configure the gem compilation before running bundle install :

bundle config build.ruby2d --with-cflags=\"-std=c99\"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM