[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Handling dynamic libraries with Libtool and Ruby on Mac OS X

From: Roland Levillain
Subject: Handling dynamic libraries with Libtool and Ruby on Mac OS X
Date: Thu, 13 Jul 2006 17:11:01 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)


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 original `Kernel.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/' for each Libtool module named `' in the

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.

[1]   The Olena project,

[2]   System hooks for loading Libtool libraries
- in Python:*checkout*/gnome-python/trunk/pygobject/
- in Ruby:

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


[5]   The Tiger project,

Roland Levillain

reply via email to

[Prev in Thread] Current Thread [Next in Thread]