2

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)
IAmInPLS
  • 4,051
  • 4
  • 24
  • 57
Flare Cat
  • 591
  • 2
  • 12
  • 24
  • Check the binary file in the bundle `Windmill-Animation-Executer.app`. Does it have the same name? – IAmInPLS Jun 08 '16 at 12:10
  • @IAmInPLS Yes, it has the same name – Flare Cat Jun 08 '16 at 12:11
  • Can you type in your command line `otool -L Windmill-...app/Contents/MacOS/Windmill..` and post the result in your question? – IAmInPLS Jun 08 '16 at 12:15
  • @IAmInPLS Alright, please give me a minute. – Flare Cat Jun 08 '16 at 12:15
  • @IAmInPLS Ok, I added it. – Flare Cat Jun 08 '16 at 12:18
  • Oh wait, you don't have any error in fact! Only warnings, right? – IAmInPLS Jun 08 '16 at 12:20
  • @IAmInPLS Yes, but then when I try to run the actual app itself with `open -a ....app`, I get the following: `LSOpenURLsWithRole() failed for the application /Users/etcg/Documents/qt/build-Windmill-Animation-Executer-Desktop_Qt_5_6_0_clang_64bit-Release/Windmill-Animation-Executer.app with error -10810.` (after using macdeployqt) – Flare Cat Jun 08 '16 at 12:21
  • @IAmInPLS Also, when running the executable itself, I get the following output: `dyld: Library not loaded: @rpath/QtQuick.framework/Versions/5/QtQuick Referenced from: /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 Reason: image not found Trace/BPT trap: 5` – Flare Cat Jun 08 '16 at 12:25
  • Try something like this `install_name_tool -change @rpath/QtQuick.framework/Versions/5/QtQuick @executable_path/../../../../../QtQuick.framework/Versions/5/QtQuick /Users/etcg/Documents/qt/build-Windmill-Animation-Executer-Desktop_Qt_5_6_0_clan‌​g_64bit-Release/Windmill-Animation-Executer.app/Contents/MacOS/Windmill-Animation‌​-Executer` (not sure about everything but basically I think the `rpath` is wrongly recognized. So you have to replace the QtQuick framework path yourself) – IAmInPLS Jun 08 '16 at 12:41
  • @IAmInPLS Sorry, what does the `/../../../../..` represent? – Flare Cat Jun 09 '16 at 14:21
  • The path from the executable to `QtQuick.framework`. It might not be the same for you, that's why I said I was not sure – IAmInPLS Jun 09 '16 at 14:25
  • @IAmInPLS Oh, thought it meant I had to include something else. Forgot that `/../` brings you back a directory. I'll test out that command and report back now. – Flare Cat Jun 09 '16 at 14:28
  • @IAmInPLS Ok, command provided no output, but now the app still won't open. What should I do now? By the way, thanks for all of your help. – Flare Cat Jun 09 '16 at 14:32
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/114246/discussion-between-iaminpls-and-flare-cat). – IAmInPLS Jun 09 '16 at 14:35

1 Answers1

4

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.

Community
  • 1
  • 1
IAmInPLS
  • 4,051
  • 4
  • 24
  • 57
  • Ok, thanks for making an official answer. Now my application says it can't find the Cocoa framework on the target computer. Is this a simple fix, or should I post another question? – Flare Cat Jun 10 '16 at 15:00
  • I think you can ask a new question! – IAmInPLS Jun 11 '16 at 10:22