A change was made to tclLoadDyld.c to use the dlfcn API (dlopen) on MacOSX 10.4 or later instead of the obsolete/deprecated NSModule API.
However, the call to dlopen is problematic:
dlHandle = dlopen(nativePath, RTLD_NOW | RTLD_LOCAL);
RLTD_LOCAL is *not* the default value for dlopen, the default is RTLD_GLOBAL. RLTD_LOCAL prevents Tcl/Tk from being able to load any dynamic library/module which depends (i.e. was linked against) a previously loaded dynamic library/module.
Unless I missed the rational for picking RLTD_LOCAL, could Tcl/Tk please use the default RLTD_GLOBAL?
RTLD_GLOBAL: Symbols exported from this image (dynamic library or bundle) will be available to any images build with -flat_namespace option to ld(1) or to calls to dlsym() when using a spe-cial specialcial handle.
RTLD_LOCAL: Symbols exported from this image (dynamic library or bundle) are generally hidden and only availble to dlsym() when directly using the handle returned by this call to dlopen().
In the second case, a library/module A will load correctly but will hide its symbols. Tcl/Tk will fail to load a library/module B if B depends on symbols in A (i.e. was dynamically linked against A).
barre  $ /opt/tcltk8.5.0/bin/wish8.5
% load libvtkCommonTCL.dylib
% load libvtkFilteringTCL.dylib
dlopen(libvtkFilteringTCL.dylib, 6): Symbol not found: __Z14vtkTclInDeleteP10Tcl_Interp
Referenced from: /Users/barre/build/VTK-VTK-5-2-tcl85-debug/bin/libvtkFilteringTCL.dylib
Expected in: flat namespace
the __Z14vtkTclInDeleteP10Tcl_Interp symbol *is* actually in libvtkCommonTCL.dylib.
barre  $ otool -L libvtkFilteringTCL.dylib
libvtkFilteringTCL.5.2.dylib (compatibility version 0.0.0, current version 0.0.0)
libvtkFiltering.5.2.dylib (compatibility version 0.0.0, current version 0.0.0)
libvtkCommonTCL.5.2.dylib (compatibility version 0.0.0, current version 0.0.0)
libvtkCommon.5.2.dylib (compatibility version 0.0.0, current version 0.0.0)
/opt/tcltk8.5.0/lib/libtcl8.5.dylib (compatibility version 8.5.0, current version 8.5.0)
Manually changing RLTD_LOCAL to RLTD_GLOBAL, I was able to load both libraries without any problem inside Tcl/Tk 8.5.2.