3

I finished my mac app using Xcode and Qt. Now I would like to prepare it for deployment to other macs. Inorder to do that I utilized macdeployqt.

I just created an app bundle with macdeployqt. However some of the libraries are missing. I attempted to follow [this][1] answer. Turns out I need to copy the missing dylib from my computer to the .app and then run install name tool. I have not gotten to the install-name tool yet as I am confused as to use -id or -change with it especially in my current scenario. Do I even need to use it ? Here is what I did so far.

Step 1: Running macdeployqt - this is a program that comes with Qt and embeds the necessary requirements of qt into the app.

> /Users/Guest/Qt/5.5/clang_64/bin/macdeployqt project2.app

Step 2: I then decided to run otool on the actual generated app binary

> pwd
/Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS
> otool -L project2 

project2:
    @rpath/libcreatecore_rt.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/QtQuick.framework/Versions/5/QtQuick (compatibility version 5.5.0, current version 5.5.1)
    @rpath/QtConcurrent.framework/Versions/5/QtConcurrent (compatibility version 5.5.0, current version 5.5.1)
    @rpath/QtSvg.framework/Versions/5/QtSvg (compatibility version 5.5.0, current version 5.5.1)
    /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
    @executable_path/../Frameworks/libosg.141.dylib (compatibility version 141.0.0, current version 3.5.1)
    @executable_path/../Frameworks/libosgDB.141.dylib (compatibility version 141.0.0, current version 3.5.1)
    @executable_path/../Frameworks/libosgGA.141.dylib (compatibility version 141.0.0, current version 3.5.1)
    @executable_path/../Frameworks/libosgUtil.141.dylib (compatibility version 141.0.0, current version 3.5.1)
    @executable_path/../Frameworks/libosgViewer.141.dylib (compatibility version 141.0.0, current version 3.5.1)
    @executable_path/../Frameworks/libosgManipulator.141.dylib (compatibility version 141.0.0, current version 3.5.1)
    @executable_path/../Frameworks/libOpenThreads.20.dylib (compatibility version 20.0.0, current version 3.3.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
    /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 22.0.0)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1256.14.0)
    /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
    @rpath/libtbb.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libtbb_debug.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libtbbmalloc_debug.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libtbbmalloc_proxy.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libtbbmalloc_proxy_debug.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libtbb_preview.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libtbb_preview_debug.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libquazip.1.dylib (compatibility version 1.0.0, current version 1.0.0)
    @executable_path/../Frameworks/libprotobuf.9.dylib (compatibility version 10.0.0, current version 10.1.0)
    @rpath/QtQml.framework/Versions/5/QtQml (compatibility version 5.5.0, current version 5.5.1)
    @rpath/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.5.0, current version 5.5.1)
    @rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.5.0, current version 5.5.1)
    @rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.5.0, current version 5.5.1)
    @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.5.0, current version 5.5.1)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)

Step 3: However I noticed that my project2.app/Contents/Frameworks does not have those libraries inside them. So I decided to copy them manually.

cp /usr/local/lib/libosg.141.dylib              project2.app/Contents/Frameworks/libosg.141.dylib
cp /usr/local/lib/libosgDB.141.dylib            project2.app/Contents/Frameworks/libosgDB.141.dylib
cp /usr/local/lib/libosgGA.141.dylib            project2.app/Contents/Frameworks/libosgGA.141.dylib
cp /usr/local/lib/libosgUtil.141.dylib          project2.app/Contents/Frameworks/libosgUtil.141.dylib
cp /usr/local/lib/libosgViewer.141.dylib        project2.app/Contents/Frameworks/libosgViewer.141.dylib
cp /usr/local/lib/libosgManipulator.141.dylib   project2.app/Contents/Frameworks/libosgManipulator.141.dylib
cp /usr/local/lib/libOpenThreads.20.dylib       project2.app/Contents/Frameworks/libOpenThreads.20.dylib

Could you tell me what my next steps should be after copying those files ?

This is the output that I get when I attempt to run the app on another computer without using install_name_tool

Dyld Error Message:
  Library not loaded: libosgUtil.141.dylib
  Referenced from: /Users/one/Desktop/project2.app/Contents/Frameworks/libosgDB.141.dylib
  Reason: image not found

Binary Images:
    0x7fff6c436000 -     0x7fff6c46c837  dyld (353.2.1) <65DCCB06-339C-3E25-9702-600A28291D0E> /usr/lib/dyld

Update:

After some struggling I decided to do the following

install_name_tool -change libosg.141.dylib  @executable_path/../Frameworks/libosg.141.dylib  /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libosgDB.141.dylib  @executable_path/../Frameworks/libosgDB.141.dylib  /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libosgGA.141.dylib    @executable_path/../Frameworks/libosgGA.141.dylib       /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libosgUtil.141.dylib  @executable_path/../Frameworks/libosgUtil.141.dylib     /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libosgViewer.141.dylib       @executable_path/../Frameworks/libosgViewer.141.dylib        /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libosgManipulator.141.dylib  @executable_path/../Frameworks/libosgManipulator.141.dylib   /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
install_name_tool -change libOpenThreads.20.dylib      @executable_path/../Frameworks/libOpenThreads.20.dylib       /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2

That did not seem to solve the problem as when I did this to one of the libraries that I just had added.

otool -L libosgDB.141.dylib 
libosgDB.141.dylib:
    @executable_path/../Frameworks/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)   <-----!!!Why did this not change!!!!!
    /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)     <-----!!!Why did this not change!!!!!
    libOpenThreads.20.dylib (compatibility version 20.0.0, current version 3.3.0)<-----!!!Why did this not change!!!!!
    /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)

I am still not getting paths for the libraries libOpenThreads.20.dylib , libosgUtil.141.dylib and libosg.141.dylib any suggestions would be more than welcome.

MistyD
  • 16,373
  • 40
  • 138
  • 240

1 Answers1

3

libosg.141.dylib is a dylib that you're including in your built app.

You should actually look in your app's binary... that is:

otool -L /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2

As for resetting the path of the library to point to "@executable_path/../Frameworks/libosg.141.dylib" instead of the dylib in "/usr/local/lib", try doing this:

install_name_tool -change libosg.141.dylib @executable_path/../Frameworks/libosg.141.dylib /Users/Guest/project_XCODE/bin/Release/project2.app/Contents/MacOS/project2
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
  • You don't need to change the install name of the library. That's useful **before** linking to it so that the linker uses that install name as the reference to it in the linked executable. Since you're manipulating things after linking, there's no point in that. – Ken Thomases Feb 03 '16 at 19:55
  • @MichaelDautermann thanks for the post. I just updated my post with more information. Could you kindly tell me what my next step should be ? Earlier I did not mention the result of otool on the binary before copying the libraries to the framework. Hope this would make my issue more clear ? – MistyD Feb 03 '16 at 21:46
  • @MistyD I don't see a question there. Did you get everything figured out? – Michael Dautermann Feb 05 '16 at 03:05
  • Yes I am reading more on this topic. Here is the link http://stackoverflow.com/questions/35220111/install-name-tool-difference-between-change-and-id – MistyD Feb 05 '16 at 09:07
  • Can you please have a look in this : https://stackoverflow.com/questions/46088104/adding-external-libraries-deploying-qt-app-mac-osx – arqam Sep 07 '17 at 10:29