From: Luis Lavena Date: 2011-08-11T23:32:24+09:00 Subject: Re: Supporting both ruby 1.8 and 1.9 in a compiled library James Masters wrote in post #1016122: > Hi all, > > I am a maintainer of the Ruby interface to a C++ library wrapped using > SWIG. Up until now I have only supported Ruby 1.8 but I'm now adding > support for Ruby 1.9. Are there any recommendations for how to allow > both compiled copies of this wrapped library to be on the load path > ($RUBYLIB) given that the *.so files are different for 1.8 and 1.9? > (Some of my users will use 1.8 and others will use 1.9 but $RUBYLIB is > shared). I was thinking of my own solution similar to (module is "oa"): > > oa.rb > oa/1.8/x86_64-linux/*.so > oa/1.9/x86_64-linux/*.so > Perhaps you can take a look to rake-compiler: http://github.com/luislavena/rake-compiler Which provides what is called "fat-binaries" and version out the directory of Ruby implementation using this technique. The other approach is use the RbConfig::CONFIG["ruby_version"] which will provide you the API compatibility version, so 1.8 for 1.8.6, 1.8.7 and 1.9.1 for Ruby 1.9.1, 1.9.2 and 1.9.3 > And the oa.rb file will have custom code written to dispatch to one set > of the *.so files based on the Ruby version. Are there any better ways? > Sorry if this is a basic question... I could not find the answer by > doing some Internet searches. > > I'd prefer to not use gems for this since I will not distribute it > online and Ruby 1.8 is not guaranteed to have rubygems installed (trying > to keep this as flexible and simple as possible). > Then you should use "setup.rb" which will install the compiled extension in the platform specific folder, except for the versioned part. Good luck, -- Luis Lavena -- Posted via http://www.ruby-forum.com/.