Search code examples
c++qtdeploymentqmlmacdeployqt

Macdeployqt could not find any external Qt frameworks to deploy


I made a simple animation in Qt/Qml. I can build the release version fine, with no errors. It also runs correctly. As the project is finished, I tried to deploy it with macdeployqt like this :

./Qt/5.6/clang_64/bin/macdeployqt /Users/etcg/Documents/qt/build-Windmill-Animation-Executer-Desktop_Qt_5_6_0_clang_64bit-Release/Windmill-Animation-Executer.app

but it gives me the following errors:

WARNING:
WARNING: Could not find any external Qt frameworks to deploy in "/Users/etcg/Documents/qt/build-Windmill-Animation-Executer-Desktop_Qt_5_6_0_clang_64bit-Release/Windmill-Animation-Executer.app"
WARNING: Perhaps macdeployqt was already used on "/Users/etcg/Documents/qt/build-Windmill-Animation-Executer-Desktop_Qt_5_6_0_clang_64bit-Release/Windmill-Animation-Executer.app" ?
WARNING: If so, you will need to rebuild "/Users/etcg/Documents/qt/build-Windmill-Animation-Executer-Desktop_Qt_5_6_0_clang_64bit-Release/Windmill-Animation-Executer.app" before trying again.

Am I doing something wrong, or is there something wrong with my Qt installation? How do I fix this problem?

Note: This is my first time using macdeployqt.


Edit :

In order to check the libraires dependencies, I ran otool -L.

The result of otool -L /Users/etcg/Documents/qt/build-Windmill-Animation-Executer-Desktop_Qt_5_6_0_clang_64bit-Release/Windmill-Animation-Executer.app/Contents/MacOS/Windmill-Animation-Executer is this :

/Users/etcg/Documents/qt/build-Windmill-Animation-Executer-Desktop_Qt_5_6_0_clang_64bit-Release/Windmill-Animation-Executer.app/Contents/MacOS/Windmill-Animation-Executer:
    @rpath/QtQuick.framework/Versions/5/QtQuick (compatibility version 5.6.0, current version 5.6.0)
    @rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.6.0, current version 5.6.0)
    @rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.6.0, current version 5.6.0)
    @rpath/QtQml.framework/Versions/5/QtQml (compatibility version 5.6.0, current version 5.6.0)
    @rpath/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.6.0, current version 5.6.0)
    @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.6.0, current version 5.6.0)
    /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
    /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)

Solution

  • Following our discussion in the chat, it seems that you managed to get it working, so that's great! As I suspected, your @rpath was misleading (Qt's fault I guess). So the way to fix it is to link the Qt libraries using @executable_path instead of @rpath (you can go here to know the difference).

    To do that, follow these steps :

    1/ Run the executable itself : you will get an error message like this :

    dyld: Library not loaded: @rpath/Qt*.framework/Versions/5/Qt*

    Referenced from: your_executable_name

    Reason: image not found Trace/BPT trap: 5

    where * is the name of the Qt library. You are told that the library is not well referenced so you have to change the path where it is referenced from.

    2/ To do that, use the command install_name_tool like that :

    install_name_tool -change @rpath/Qt*.framework/Versions/5/Qt* @executable_path/your/path/to/the/framework/Qt*.framework/Versions/5/Qt* /your/path/to/your/executable
    

    Now, you have changed the path (you can check that with otool -L).

    3/ If the change is correct, either you have no problem anymore, or you have to do this for other Qt libs. Indeed, * can be Quick, but it can also be Gui, Network, etc (Qt libs in fact). So go back to step 1!

    Once you're done with all the libs, your application starts as you desired.