Forum: Ruby requiring extensions

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
60df0375cbd8c1d72390d7edd514a4a0?d=identicon&s=25 hans (Guest)
on 2005-11-14 20:53
(Received via mailing list)
I'm wrapping a library with swig, and I'd like to also implement some
rubyisms for it in a regular ruby file. So I have:

ext/sndfile/extconf.rb
ext/sndfile/sndfile.i
ext/sndfile/sndfile.h
lib/sndfile.rb

I'd like to have lib/sndfile.rb require the shared library. In the past
I've done this with require 'foo.so', which worked great on linux but it
occurs to me that it's not very cross-platform. (On my iBook for example
the output is sndfile.bundle)

Is there an elegant way to require the shared library and not the ruby
lib? Or do I just need to name my shared library something else? (or
vice versa) I'd like people to just be able to do

  require 'sndfile'
Dd76a12d66f843de5c5f8782668e7127?d=identicon&s=25 mfp (Guest)
on 2005-11-14 23:47
(Received via mailing list)
On Tue, Nov 15, 2005 at 04:52:16AM +0900, Hans Fugal wrote:
> occurs to me that it's not very cross-platform. (On my iBook for example
> the output is sndfile.bundle)

this might help you:

require 'rbconfig'
[RUBY_PLATFORM, RUBY_VERSION]      # => ["i686-linux", "1.8.3"]
Config::CONFIG["DLEXT"]            # => "so"
04a56914cc09f0858d3fca2bf4cbde34?d=identicon&s=25 nobuyoshi.nakada (Guest)
on 2005-11-15 04:06
(Received via mailing list)
Hi,

At Tue, 15 Nov 2005 04:52:16 +0900,
Hans Fugal wrote in [ruby-talk:165742]:
> I'd like to have lib/sndfile.rb require the shared library. In the past
> I've done this with require 'foo.so', which worked great on linux but it
> occurs to me that it's not very cross-platform. (On my iBook for example
> the output is sndfile.bundle)

".so" is handled specically as the platform dependent suffix,
i.e., ".bundle" on MacOSX.
60df0375cbd8c1d72390d7edd514a4a0?d=identicon&s=25 hans (Guest)
on 2005-11-15 05:45
(Received via mailing list)
On Tue, 15 Nov 2005 at 12:03 +0900, nobuyoshi nakada wrote:
> ".so" is handled specically as the platform dependent suffix,
> i.e., ".bundle" on MacOSX.

So it does. I wonder what I fat-fingered when I thought I tried this in
irb. Thank you both for your answers.
This topic is locked and can not be replied to.