4

Yet another dyld: Library not loaded dylib problem..

I've got a dylib (libboost_system.dylib) compiled from the Boost sources,
then used install-name-tool to prepare it for inclusion in the Frameworks folder of my app bundle like so:

install_name_tool -id @executable_path
    /../Frameworks/
    libboost_system.dylib libboost_system.dylib

Verified with otool:

$> otool -L libboost_system.dylib

/Users/TesterCodeSandbox/OgreSDK
    /BOOST_DYLIBS/libboost_system.dylib:
@executable_path/../Frameworks
    /libboost_system.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)

Now added to the Xcode project, linked against the app and copied to the Frameworks folder.
But when checking the built app with otool -L it's still referring to the original (i.e. 'non-relocated') dylib:

OgreTest-ekeeqmnyciddaxbzyrehtcoijcki/Build
        /Products/Debug/OgreTest.app/Contents/MacOS/OgreTest:
    @executable_path/../Plugins
            /RenderSystem_GL.dylib (compatibility version 0.0.0, current version 1.8.0)
    /System/Library/Frameworks/Cocoa.framework/
            Versions/A/Cocoa (compatibility version 1.0.0, current version 15.0.0)
    @executable_path/../Frameworks/Ogre.framework/
            Versions/1.8.0/Ogre (compatibility version 0.0.0, current version 1.8.0)
    @executable_path/../Frameworks/Cg.framework
            /Cg (compatibility version 0.0.0, current version 0.0.0)
    /System/Library/Frameworks/IOKit.framework/Versions/A
            /IOKit (compatibility version 1.0.0, current version 275.0.0)
    /System/Library/Frameworks/Carbon.framework/Versions/A
            /Carbon (compatibility version 2.0.0, current version 152.0.0)
    libboost_system.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libstdc++.6.dylib 
            (compatibility version 7.0.0, current version 7.9.0)
    /usr/lib/libSystem.B.dylib 
            (compatibility version 1.0.0, current version 125.2.11)
    /usr/lib/libobjc.A.dylib 
            (compatibility version 1.0.0, current version 227.0.0)
    /System/Library/Frameworks/CoreFoundation.framework
            /Versions/A/CoreFoundation 
            (compatibility version 150.0.0, current version 550.43.0)
    /System/Library/Frameworks/AppKit.framework
            /Versions/C/AppKit 
            (compatibility version 45.0.0, current version 1038.36.0)

And the app fails to start with the 'dyld: Library not loaded: libboost_system.dylib' error. Any ideas?


Note 1

Now it does work if I also post-process my app's binary with install_name_tool, i.e.:

install_name_tool -change libboost_system.dylib @executable_path/../Frameworks/libboost_system.dylib TestApp

Am I missing some Xcode option to force the compiler to change the dylib location in my app automatically as part of the build?

Surely invoking install_name_tool manually for the application consuming the dylib (i.e. one of potentially many) can just be a work-around for something I've screwed up when configuring the (application) project....

4

0 に答える 0