need help debugging wierd dlopen failure
If someone could give me some clues about how to debug this it would be great. I'm trying to figure out why "it" fails to load a particular dylib under macOS. "it" meaning that I'm not sure who is actually failing, but I suspect it is actually a failure detected and reported by dlopen(3) itself, rather than something wrong in cffi. The problem seems to be that loading libgdk-x11-2.0.0.dylib triggers a complaint about a library I have loaded from a different place, but the error message indicates a location I have not loaded my LD_LIBRARY_PATH. Could it possibly be that libgdk-x11-2.0.0.dylib has a hard coded path in it pointing to /usr/local/lib ? If someone could give me some clues about how to debug this it would be great. I've set up my LD_LIBRARY_PATH so that it seems to be loading the correct libcairo.2.dylib from /usr/local/Cellar/cairo/1.12.16_1/lib/libcairo.2.dylib. The reason I think this is because both vmmap (unix command line) and cffi::list-foreign-libraries (lisp) give compatible results. sh> vmmap -w 16787 | grep dylib | sed -e 's/^.*SM=... //' | grep cairo /usr/local/Cellar/cairo/1.14.6_1/lib/libcairo.2.dylib sh> and CL-USER> (cffi::list-foreign-libraries) (... #<CFFI:FOREIGN-LIBRARY :LIBCAIRO #P"/usr/local/Cellar/cairo/1.12.16_1/lib/libcairo.dylib" (truename=#P"/usr/local/Cellar/cairo/1.12.16_1/lib/libcairo.2.dylib")>) CL-USER> However, when I attempt to load libgdk-x11-2.0.0.dylib it complains that it cannot find a particular symbol in /usr/local/lib/libcairo.dylib. Why is it complaining about /usr/local/lib/libcairo.dylib? Unable to load any of the alternatives: ("libgdk-x11-2.0.0.dylib" "libgdk-x11-2.0.dylib") Attempting to load GDK::GDK from lib "libgdk-x11-2.0.dylib" (%LOAD-FOREIGN-LIBRARY GDK /usr/local/Cellar/gtk+/2.24.24/lib/libgdk-x11-2.0.0.dylib) Unable to load foreign library (GDK::GDK). Error opening shared object "/usr/local/Cellar/gtk+/2.24.24/lib/libgdk-x11-2.0.0.dylib": dlopen(/usr/local/Cellar/gtk+/2.24.24/lib/libgdk-x11-2.0.0.dylib, 10): Symbol not found: _cairo_xlib_surface_create Referenced from: /usr/local/Cellar/gtk+/2.24.24/lib/libgdk-x11-2.0.0.dylib Expected in: /usr/local/lib/libcairo.dylib in /usr/local/Cellar/gtk+/2.24.24/lib/libgdk-x11-2.0.0.dylib. Attempting to load GDK::GDK from lib "libgdk-x11-2.0.0.dylib" (%LOAD-FOREIGN-LIBRARY GDK /usr/local/Cellar/gtk+/2.24.24/lib/libgdk-x11-2.0.0.dylib) Unable to load foreign library (GDK::GDK). Error opening shared object "/usr/local/Cellar/gtk+/2.24.24/lib/libgdk-x11-2.0.0.dylib": dlopen(/usr/local/Cellar/gtk+/2.24.24/lib/libgdk-x11-2.0.0.dylib, 10): Symbol not found: _cairo_xlib_surface_create Referenced from: /usr/local/Cellar/gtk+/2.24.24/lib/libgdk-x11-2.0.0.dylib Expected in: /usr/local/lib/libcairo.dylib in /usr/local/Cellar/gtk+/2.24.24/lib/libgdk-x11-2.0.0.dylib. [Condition of type CFFI:LOAD-FOREIGN-LIBRARY-ERROR]
On Tue, Sep 20, 2016 at 10:53 AM, Jim Newton <jimka.issy@gmail.com> wrote:
CL-USER> (cffi::list-foreign-libraries) (... #<CFFI:FOREIGN-LIBRARY :LIBCAIRO #P"/usr/local/Cellar/cairo/1.12.16_1/lib/libcairo.dylib" (truename=#P"/usr/local/Cellar/cairo/1.12.16_1/lib/libcairo.2.dylib")>) CL-USER>
However, when I attempt to load libgdk-x11-2.0.0.dylib it complains that it cannot find a particular symbol in /usr/local/lib/libcairo.dylib. Why is it complaining about /usr/local/lib/libcairo.dylib?
Most of those dylibs are symlinks and libgdk may depend on a name which exists in /usr/local/lib but not /usr/local/Cellar, maybe? ldd can tell you what a given dylib depends on. Cheers, -- Luís Oliveira http://kerno.org/~luis/
Am 20.09.2016 um 15:32 schrieb Luís Oliveira <luismbo@gmail.com>:
On Tue, Sep 20, 2016 at 10:53 AM, Jim Newton <jimka.issy@gmail.com> wrote:
CL-USER> (cffi::list-foreign-libraries) (... #<CFFI:FOREIGN-LIBRARY :LIBCAIRO #P"/usr/local/Cellar/cairo/1.12.16_1/lib/libcairo.dylib" (truename=#P"/usr/local/Cellar/cairo/1.12.16_1/lib/libcairo.2.dylib")>) CL-USER>
However, when I attempt to load libgdk-x11-2.0.0.dylib it complains that it cannot find a particular symbol in /usr/local/lib/libcairo.dylib. Why is it complaining about /usr/local/lib/libcairo.dylib?
Most of those dylibs are symlinks and libgdk may depend on a name which exists in /usr/local/lib but not /usr/local/Cellar, maybe? ldd can tell you what a given dylib depends on.
As Jim is on macOS there is no ldd. The command to use is otool -L /usr/local/lib//libcairo.dylib Seeing that Jim uses homebrew to install Cairo it is worth mentioning that brew install … also generates (normally) an entry in /usr/local/lib . That is why I always stick to using /usr/local/lib/libxyz.dylib paths when I want to ensure a particular library to be loaded. Best, Frank
Hi Frank, thanks for the information. If you always use /usr/local/lib then what do you do when you need to run two different independent applications which have different requirements? On Tue, Sep 20, 2016 at 3:44 PM, Frank Goenninger <frgo@me.com> wrote:
Am 20.09.2016 um 15:32 schrieb Luís Oliveira <luismbo@gmail.com>:
On Tue, Sep 20, 2016 at 10:53 AM, Jim Newton <jimka.issy@gmail.com>
CL-USER> (cffi::list-foreign-libraries) (... #<CFFI:FOREIGN-LIBRARY :LIBCAIRO #P"/usr/local/Cellar/cairo/1.12.16_1/lib/libcairo.dylib" (truename=#P"/usr/local/Cellar/cairo/1.12.16_1/lib/libcairo.2.dylib")>) CL-USER>
However, when I attempt to load libgdk-x11-2.0.0.dylib it complains
wrote: that it cannot find a particular symbol in /usr/local/lib/libcairo.dylib. Why is it complaining about /usr/local/lib/libcairo.dylib?
Most of those dylibs are symlinks and libgdk may depend on a name which exists in /usr/local/lib but not /usr/local/Cellar, maybe? ldd can tell you what a given dylib depends on.
As Jim is on macOS there is no ldd. The command to use is
otool -L /usr/local/lib//libcairo.dylib
Seeing that Jim uses homebrew to install Cairo it is worth mentioning that brew install … also generates (normally) an entry in /usr/local/lib . That is why I always stick to using /usr/local/lib/libxyz.dylib paths when I want to ensure a particular library to be loaded.
Best, Frank
Jim, loading a specific version of a shared library requires two things: a. Use absolute path to the library in the cffi lib spec b. Make sure the dependencies (see output of otool -L ) (the paths to the dependencies) are at the beginning of the paths set in the environment variable DYLD_LIBRARY_PATH. Best Frank -- Frank Gönninger DG1SBG Consequor Consulting AG
Am 20.09.2016 um 16:46 schrieb Jim Newton <jimka.issy@gmail.com>:
Hi Frank, thanks for the information. If you always use /usr/local/lib then what do you do when you need to run two different independent applications which have different requirements?
On Tue, Sep 20, 2016 at 3:44 PM, Frank Goenninger <frgo@me.com> wrote: Am 20.09.2016 um 15:32 schrieb Luís Oliveira <luismbo@gmail.com>:
On Tue, Sep 20, 2016 at 10:53 AM, Jim Newton <jimka.issy@gmail.com> wrote:
CL-USER> (cffi::list-foreign-libraries) (... #<CFFI:FOREIGN-LIBRARY :LIBCAIRO #P"/usr/local/Cellar/cairo/1.12.16_1/lib/libcairo.dylib" (truename=#P"/usr/local/Cellar/cairo/1.12.16_1/lib/libcairo.2.dylib")>) CL-USER>
However, when I attempt to load libgdk-x11-2.0.0.dylib it complains that it cannot find a particular symbol in /usr/local/lib/libcairo.dylib. Why is it complaining about /usr/local/lib/libcairo.dylib?
Most of those dylibs are symlinks and libgdk may depend on a name which exists in /usr/local/lib but not /usr/local/Cellar, maybe? ldd can tell you what a given dylib depends on.
As Jim is on macOS there is no ldd. The command to use is
otool -L /usr/local/lib//libcairo.dylib
Seeing that Jim uses homebrew to install Cairo it is worth mentioning that brew install … also generates (normally) an entry in /usr/local/lib . That is why I always stick to using /usr/local/lib/libxyz.dylib paths when I want to ensure a particular library to be loaded.
Best, Frank
participants (3)
-
Frank Goenninger
-
Jim Newton
-
Luís Oliveira