Forum: Ruby .rb file includes c-extension of same name?

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.
4feed660d3728526797edeb4f0467384?d=identicon&s=25 Bill Kelly (Guest)
on 2006-03-20 03:40
(Received via mailing list)
Hi,

I have foo.rb and foo.so, the C-extension part of the module.

Inside foo.rb, I can put, require 'foo.so', and it works fine,
allowing other modules to say require 'foo', and have the .rb
be loaded, which in turn loads the C-extension.

I'm wondering if there's a recommended platform-independent
way to do this?  For instance, on OS X, C-extensions end in
".bundle" not ".so".

I wouldn't mind even saying require "foo.#{DLEXT}", if there
were such a thing available from ruby.

Is there a recommended way to have a .rb file require a
C-extension file of the same name in a platform-independent
way?  Or is the preferred solution to alter the name of one
of the two files?


Thanks,

Bill
Cb48ca5059faf7409a5ab3745a964696?d=identicon&s=25 unknown (Guest)
on 2006-03-20 06:24
(Received via mailing list)
On Mon, 20 Mar 2006, Bill Kelly wrote:

> ".bundle" not ".so".
> Thanks,
>
> Bill

harp:~ > ruby -r yaml -r rbconfig -e'  y Config::CONFIG  '|egrep DLEXT
DLEXT2: ""
DLEXT: so


-a
4feed660d3728526797edeb4f0467384?d=identicon&s=25 Bill Kelly (Guest)
on 2006-03-20 06:41
(Received via mailing list)
From: <ara.t.howard@noaa.gov>
>
> harp:~ > ruby -r yaml -r rbconfig -e'  y Config::CONFIG  '|egrep DLEXT
> DLEXT2: ""
> DLEXT: so

Aha!  TYVM.  I'd been grepping the C source. . . .


Regards,

Bill
851246810c70dbfcc1815c636b054562?d=identicon&s=25 George Ogata (Guest)
on 2006-03-20 11:19
(Received via mailing list)
"Bill Kelly" <billk@cts.com> writes:

> ".bundle" not ".so".
> Thanks,
>
> Bill

An alternative: call the C bit "foo_ext.so" (say) and then in "foo.rb"
just do "require 'foo_ext'"?
37a3c73ffbf864e4b28f7f2384ee12ce?d=identicon&s=25 Timothy Hunter (tim-hunter)
on 2006-03-20 13:18
(Received via mailing list)
Bill Kelly wrote:
> ".bundle" not ".so".
> Thanks,
>
> Bill
>
>
>
>
You can just always use ".so". Ruby is clever enough to figure out what
".so" really means on the current platform.
This topic is locked and can not be replied to.