Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Extending Gosu / making a gem
- By banister Date 2009-08-18 22:03
this isn't directly related to gosu but im sure you know the answer jlnr. How do i make a gem that compiles a C extension from source on the linux and macosx systems but on windows simply installs the .so? (adding ruby 1.9 support would be good too)
- By jlnr (dev) Date 2009-08-19 05:06
I don't know the /right/ way because rubygems' docs are virtually nonexistent for this kind of distribution, and building it all in one gem is painful and I didn't get it to work. Basically, you'd have to have a C extension conf/makefile in there that on Windows creates a fake 'make', installs it in the system, then runs a bogus makefile, uninstalls the fake 'make' and then just uses the C extension :D But as I said, that didn't work for me.

What I do is:
• on Windows, stuff an .so for 1.8, and an .so for 1.9 into the gem, then let 'gosu.rb' select either. I haven't found a prettier way. It will get much worse if the new 1.9.1pXXX release from will really be built with mingw, but hey, when you have two versions in the gem, why not three? ;)
• on Linux (and in your case, OS X) put an extconf.rb in there and set the 'extension' property or something of the gemspec. In your extconf.rb, be sure to note the current version of Ruby that is running, because there will be lots of interesting Ruby configurations on Linux and you don't want to link against the wrong lib :)
• make sure that the OS names for the gems match and that the version numbers are always the same. Otherwise, a gem with a slightly more recent version will be preferred to the older ones for the right platform during gem installation.

If you check out Gosu from source, you can take a look at the rakefile and my template gemspecs.
- By banister Date 2009-08-19 05:11
wow thanks for your comprehensive reply. ill def check out your rakefile as the process sounds a touch involved
- By ippa Date 2009-08-19 10:50
... so this means we'll soon see a crossplatform-easy-to-install TexPlay gem? :P
Up Topic Gosu / Extending Gosu / making a gem

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill