0

I'm using the StarRuby (https://github.com/hajimehoshi/starruby) library and am attempting to compile the latest version to a .so file for linking in my ruby project.

However, after acquiring the needed libraries for compilation, and running the extconf.rb file to make the Makefile, I find that the C code does not comply to the C90 format, and more than like requires the C99 format.

This is a problem because mingw does not use C99, and I am stuck on Windows.

How can I compile the above source code into a .so for requiring in ruby on Windows?

The makefile: http://pastebin.com/raw.php?i=i2ANc82g
The exact output of the makefile can be found here: http://pastebin.com/raw.php?i=VpbmyLgy
Since rolling back to libpng 1.2: http://pastebin.com/raw.php?i=TqdeADHY

  • Can you run the make with `V=1` so we can see what the compiler command line being used is? – Michael Burr Nov 22 '12 at 21:29
  • You have a lot of warnings about mixing declarations and code, but the only errors I saw were `./src/texture.c:329:18: error: dereferencing pointer to incomplete type` (and in some lines shortly thereafter). What's on that line? – Daniel Fischer Nov 22 '12 at 21:35
  • @MichaelBurr: It outputs the same thing when trying to set some verbosity. – Robert 'Jet' Rowe Nov 22 '12 at 21:38
  • @DanielFischer: `if (0 < infoPtr->num_palette && hasPalette) {` the complete source is available in the git repository linked in the question. – Robert 'Jet' Rowe Nov 22 '12 at 21:40
  • So the compiler doesn't know the type `png_infop` there. In my `png.h`, I see `typedef png_info FAR * png_infop;` and `png_info` is a typedef name for `struct png_info_struct`. Can you try compiling something that just includes `png.h` and declares e.g. `png_info foo;` to see how the compiler reacts to that in isolation? – Daniel Fischer Nov 22 '12 at 22:00
  • @DanielFischer: Ah, of course. libpng has removed that since 1.5. Rolling back to a 1.2 libpng has fixed that error, though the .so does not compile correctly still. Now it gets past to the actual creation of the .so and errors out. I've updated the original post with the latest make output. – Robert 'Jet' Rowe Nov 22 '12 at 22:21
  • 1
    The C90 warnings are there because although you have `-std=c99` you also have `-Wdeclaration-after-statement`. This likely comes from the config that your Ruby was compiled with. Try adding the line `CONFIG['warnflags'].gsub! /-Wdeclaration-after-statement/, ''` to the `extconf.rb` to remove the warning. – matt Nov 22 '12 at 22:37
  • @matt: Thank you, that certainly at least clears up most of the log. – Robert 'Jet' Rowe Nov 22 '12 at 22:45

1 Answers1

1

Add this line to your Makefile:

$CFLAGS += " -std=c99"
Oleksandr Kravchuk
  • 5,963
  • 1
  • 20
  • 31
  • That is already one of the arguments in the makefile, I apologize for not including the actual makefile in the original question. It has been added. – Robert 'Jet' Rowe Nov 22 '12 at 21:23