I maintain a software system (the ECLiPSe logic programming platform) that provides an interface to Tcl/Tk across different platforms (Mac OS X, Linux,
Solaris, Windows...). I have run into a problem with Mac Tcl 8.5, which
seems to have introduced an incompatibility in the load command with
all other platforms, as well as 8.4 and earlier versions of Mac Tcl.
problem is that in 8.5, when loading a dylib file using load, and the
dylib file was compiled/ld with -flat-namespace option, the symbols in
the file is no longer visible to other dylib files that are loaded.
my case, we load two dylib files in succession, say lib1.dylib and
lib2.dylib, and lib2 references symbols in lib1 (it makes calls to
procedures defined in lib1). With Mac Tcl 8.5, the second load,
gives an error:
dlopen(./lib2.dylib, 6): Symbol not found: XXXX
where XXXX is a symbol defined in file1.dylib.
Looking at the source, in TclLoadDyld.c, dlopen() is called with
dlopen(nativePath, RTLD_NOW | RTLD_LOCAL), and this corresponds to calling it with mode 6, as shown in the error message.
is the reason for using RTLD_LOCAL here, instead of RTLD_GLOBAL?
Looking at other uses of dlopen in the source (which I assume
implements the load command for other platforms), dlopen is called with
RTLD_GLOBAL flag. The behaviour with RTLD_GLOBAL also correspond to
what I expect when I load a dynamic library -- that its symbols will be available to other dynamic libraries I use, especially when the files were compiled/ld with -flat-namespace for compatibility with other Un*x platforms.
there anyway to work around this, short of patching the source, or
building Mac Tcl with weak-linking for Mac OS X < 10.4 so that
dlopen() would not be used? The files lib1.dylib and lib2.dylib cannot
be combined into one dylib file, because lib1.dylib can be loaded on
its own in some usages.
Thanks in advance for any information!
Dear TCL Mac,
Did anyone reponsd to Kish's question? I'm interested in doing the same
thing as him: loading two different libraries with "load" and calling
the first from the second. So if he has a problem, I expect to have one too.
Kevan Hashemi, Electrical Engineer
Physics Department, Brandeis University
From: Daniel A. Steffen <das@us...> - 2009-04-16 17:13:03
On 16/04/2009, at 19:07, Kevan Hashemi wrote:
> Did anyone reponsd to Kish's question? I'm interested in doing the
> thing as him: loading two different libraries with "load" and calling
> the first from the second. So if he has a problem, I expect to have
> one too.
sorry, I meant to but forgot about it in the 8.5.7 release crunch,
this is bug 1961211 which I have just fixed for 8.5.7:
** Daniel A. Steffen **
** <mailto:das@...> **