Handling dynamic libraries with Libtool and Ruby on Mac OS X

Hello,

I’m a happy user of Libtool and Ruby, and I’m using them both in
several projects, together with the Simplified Wrapper and Interface
Generator (SWIG). Everything works well under GNU/Linux, but things
get a little bit harder on Mac OS X, and I’m posting this message on
the Libtool and Ruby mailing lists to try and get some help from both
communities. I apologize for the long message, but I prefer to give a
clear explanation.

The situation is as follows: I’m working on a C++ library[1]
(actually, this library is only composed of C++ headers, since it is a
generic library using template classes and functions); this library
dispose of bindings for the its data structures and algorithms for
Python and Ruby, thanks to SWIG.

SWIG creates C++ wrapper code to be compiled as dynamic module(s),
loaded by the target language runtime, either directly (Ruby) or via a
small glue code (Python). For the sake of portability, I recently
started to use Libtool for the creation of these dynamic modules. As
neither Python nor Ruby understands Libtool (.la') libraries, loading hooks are used[2]. It works perfectly on GNU/Linux: the interpreter looks for the Libtool library, extract the real name (``dlname'') of the dynamic module from the.la’ file, and loads it.

Things don’t work as easily on Mac OS X, as far as Ruby is concerned.
Under Mac OS X, dynamic modules produced by libtool (using the options
-avoid-version -module -shared') end with a.so’ extension (as in
GNU/Linux); hence, Libtool libraries have a dlname ending in .so'. But on Mac OS X the originalKernel.require’ method of ruby (used to
load dynamic modules into the interpreter) looks for a file ending in
`.bundle’[3] !

My current workaround is to produce a symbolic link .libs/mod.bundle' to.libs/mod.so’ for each Libtool module named `mod.la’ in the
project.

What do you people from Libtool and Ruby think about the behaviors of
Libtool and Ruby? Should libtool create .bundle' files on Mac OS X/Darwin? Or should ruby accept to load.so’ files as valid
dynamic modules on this OS?

Thanks in advance for your answers and advice!

P.S. : We created a small project that summarizes this usage of C++,
Libtool, SWIG and Python/Ruby, named after these languages/tools[4].
This experiment was successfully transposed into two project[1][5] to
create Python/Ruby wrappers over C++ code.

Notes:
[1] The Olena project, http://olena.lrde.epita.fr

[2] System hooks for loading Libtool libraries

[3] Or `.rb’, but they don’t relate to dynamic modules.

[4] http://www.lrde.epita.fr/~levill_r/c++-libtool-swig-python/c++-libtool-swig-python-0.01a.tar.gz

[5] The Tiger project, http://tiger.lrde.epita.fr

···


Roland Levillain
LRDE - http://www.lrde.epita.fr


http://lists.gnu.org/mailman/listinfo/libtool

Use the -shrext flag when linking the library on Mac OS X and specify
".bundle" as its argument.

Peter

···

On Thu, 2006-07-13 at 17:11 +0200, Roland Levillain wrote:

What do you people from Libtool and Ruby think about the behaviors of
Libtool and Ruby? Should libtool create `.bundle' files on
Mac OS X/Darwin? Or should ruby accept to load `.so' files as valid
dynamic modules on this OS?

Thanks in advance for your answers and advice!

Peter O'Gorman <peter@pogma.com> writes:

···

On Thu, 2006-07-13 at 17:11 +0200, Roland Levillain wrote:

What do you people from Libtool and Ruby think about the behaviors of
Libtool and Ruby? Should libtool create `.bundle' files on
Mac OS X/Darwin? Or should ruby accept to load `.so' files as valid
dynamic modules on this OS?

Thanks in advance for your answers and advice!

Use the -shrext flag when linking the library on Mac OS X and specify
".bundle" as its argument.

Thanks! That's what I was looking for.

_______________________________________________
http://lists.gnu.org/mailman/listinfo/libtool