Create a dmg file for qt app using macdeployqt

834 views Asked by At

I currently created a 'dmg' file using macdeployqt and encountered the following error.

   Dyld Error Message:
      Library not loaded: @executable_path/../Frameworks/libosg.141.dylib
      Referenced from: /Users/USER/*/myApp2.app/Contents/MacOS/MyApp2
      Reason: image not found

I then came across this post by @cristopher bruns which explained the situation. Essentially I needed needed to add libosg.141.dylib to the app and then add all the libraries that libosg.141.dylib was dependent on.So for instance libosg.141.dylib depends on the following 13 files.

> otool -L /usr/local/lib/libosgDB.dylib
/usr/local/lib/libosgDB.dylib:
    libosgDB.141.dylib (compatibility version 141.0.0, current version 3.5.1)
    libosgUtil.141.dylib (compatibility version 141.0.0, current version 3.5.1)
    /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 157.0.0)
    /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 22.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
    /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
    libosg.141.dylib (compatibility version 141.0.0, current version 3.5.1)
    libOpenThreads.20.dylib (compatibility version 20.0.0, current version 3.3.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1256.14.0)
    /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1256.1.0)
    /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)

My question is do I need to add all these 13 files to the app ? How deep do I need to go ? How could I know when to stop. Since each of these files might have their own dependencies ?

1

There are 1 answers

0
TheDarkKnight On

No, you only need to update the locations of dependencies for libraries that do not reside in default locations, such as libosg.141.dylib

Standard framework libraries will exist on each machine in the same location so the application can link to them during execution.

Therefore, you do not need to change entries such as:

/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 22.0.0)

and

/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)

Libraries such as libosgDB.141.dylib, libosgUtil.141.dylib, libosg.141.dylib and libOpenThreads.20.dylib need setting via install_name_tool.

The tools used for deployment are explained here.