Reputation: 4357
Just stepped through the following tutorial: http://qt-project.org/doc/qt-4.8/deployment-mac.html#the-bundle
When I ran otool on my app it looks like this:
qjson.framework/Versions/0/qjson (compatibility version 0.7.0, current version 0.7.1)
libboost_date_time.dylib (compatibility version 0.0.0, current version 0.0.0)
libQt.Shared.1.dylib (compatibility version 1.0.0, current version 1.0.0)
libQt.Framework.1.dylib (compatibility version 1.0.0, current version 1.0.0)
@executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui (compatibility version 4.8.0, current version 4.8.1)
@executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore (compatibility version 4.8.0, current version 4.8.1)
@executable_path/../Frameworks/QtNetwork.framework/Versions/4/QtNetwork (compatibility version 4.8.0, current version 4.8.1)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 625.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)
Before I did this it ran fine and was pointing to the this:
/Users/me/QtSDK1.2.1/Desktop/Qt/4.8.1/gcc/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.8.0, current version 4.8.1)
/Users/me/QtSDK1.2.1/Desktop/Qt/4.8.1/gcc/lib/QtCore.framework/Versions/4/QtCore (compatibility version 4.8.0, current version 4.8.1)
/Users/me/QtSDK1.2.1/Desktop/Qt/4.8.1/gcc/lib/QtNetwork.framework/Versions/4/QtNetwork (compatibility version 4.8.0, current version 4.8.1)
Now when I open my app it crashes straight away. When I try and open it in the terminal I get the following issue:
objc[44337]: Class QNSImageView is implemented in both
/Users/me/MyApp/MyApp.app/Contents/MacOS/./../Frameworks/QtGui.framework/Versions/4/QtGui and /Users/me/QtSDK1.2.1/Desktop/Qt/4.8.1/gcc/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
Finished by a "segment fault"
How can I make it so that I doesnt conflict? I've tried to run Qts deploy script but that didn't work either. What am I doing wrong?
Edit:
I tried to use their script again and this time Idid the following:
macdeployqt MyApp.app -dmg -no-plugins
This created a .dmg with my app in it that runs. The issue now is that nothing happens and when I ran it in the terminal I got this error:
QEventLoop: Cannot be used without QApplication
QEventLoop: Cannot be used without QApplication
What happend to my eventloop? Nothing has changed with my app since I ran it perfectly from the finder and when i deployed it and ran it from the deplyod version. Makes no sense
Update: Now I tried to remove the old app and build it from scratch using QtCreator. I then did the following:
bash-3.2$ /Users/me/Downloads/macdeployqt-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Release/macdeployqt/macdeployqt MyApp.app
copied "/Library/Frameworks/qjson.framework/Versions/0/qjson" to "MyApp.app/Contents/Frameworks/qjson.framework/Versions/0/qjson"
copied "/usr/lib/libboost_date_time.dylib" to "MyApp.app/Contents/Frameworks//libboost_date_time.dylib"
copied "/usr/lib/libQt.Shared.1.dylib" to "MyApp.app/Contents/Frameworks//libQt.Shared.1.dylib"
copied "/usr/lib/libQt.Framework.My.1.dylib" to "MyApp.app/Contents/Frameworks//libQt.Framework.My.1.dylib"
copied "/Users/me/QtSDK1.2.1/Desktop/Qt/4.8.1/gcc/lib/QtGui.framework/Versions/4/QtGui" to "MyApp.app/Contents/Frameworks/QtGui.framework/Versions/4/QtGui"
copied "/Users/me/QtSDK1.2.1/Desktop/Qt/4.8.1/gcc/lib/QtGui.framework/Resources/qt_menu.nib/classes.nib" to "MyApp.app/Contents/Frameworks/QtGui.framework/Resources/qt_menu.nib/classes.nib"
copied "/Users/me/QtSDK1.2.1/Desktop/Qt/4.8.1/gcc/lib/QtGui.framework/Resources/qt_menu.nib/info.nib" to "MyApp.app/Contents/Frameworks/QtGui.framework/Resources/qt_menu.nib/info.nib"
copied "/Users/me/QtSDK1.2.1/Desktop/Qt/4.8.1/gcc/lib/QtGui.framework/Resources/qt_menu.nib/keyedobjects.nib" to "MyApp.app/Contents/Frameworks/QtGui.framework/Resources/qt_menu.nib/keyedobjects.nib"
copied "/Users/me/QtSDK1.2.1/Desktop/Qt/4.8.1/gcc/lib/QtCore.framework/Versions/4/QtCore" to "MyApp.app/Contents/Frameworks/QtCore.framework/Versions/4/QtCore"
copied "/Users/me/QtSDK1.2.1/Desktop/Qt/4.8.1/gcc/lib/QtNetwork.framework/Versions/4/QtNetwork" to "MyApp.app/Contents/Frameworks/QtNetwork.framework/Versions/4/QtNetwork"
copied "/Users/me/QtSDK1.2.1/Desktop/Qt/4.8.1/gcc/lib/QtXml.framework/Versions/4/QtXml" to "MyApp.app/Contents/Frameworks/QtXml.framework/Versions/4/QtXml"
Deploying plugins from "/usr/plugins"
Created configuration file: "MyApp.app/Contents/Resources/qt.conf"
This file sets the plugin search path to "MyApp.app/Contents/plugins"
When I start it it still crashes, the same as before. My two libs "libQt.Shared.1.dylib" and "libQt.Framework.1.dylib" are not called that but both have symbolic links with those names. Could that have somthing to do with the crash? Or does it break the link and copies them into it? These two libs are libs that ive done myself and they are both using QtCore and QtNetwork. With otool the app looks to be poiting to the right stuff though:
@executable_path/../Frameworks/qjson.framework/Versions/0/qjson (compatibility version 0.7.0, current version 0.7.1)
@executable_path/../Frameworks/libboost_date_time.dylib (compatibility version 0.0.0, current version 0.0.0)
@executable_path/../Frameworks/libQt.Shared.1.dylib (compatibility version 1.0.0, current version 1.0.0)
@executable_path/../Frameworks/libQt.Framework.My.1.dylib (compatibility version 1.0.0, current version 1.0.0)
@executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui (compatibility version 4.8.0, current version 4.8.1)
@executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore (compatibility version 4.8.0, current version 4.8.1)
@executable_path/../Frameworks/QtNetwork.framework/Versions/4/QtNetwork (compatibility version 4.8.0, current version 4.8.1)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 625.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)
Please help me...
Upvotes: 2
Views: 2499
Reputation: 70218
I solved the error "One of the two will be used. Which one is undefined." in the following way: Since the Qt frameworks were installed to /Library/Frameworks
, dyld would look there as well when running the application. I renamed all the Qt-related frameworks (including those which do not start with "Qt", like phonon!) so they can't be found anymore. Then I ran my application again from Xcode, which allowed me to find out that actually I hadn't included all dependencies. For example, phonon itself requires QtDBus and QtXml. Since I forgot to add them to my project, dyld would use e.g. the global /Library/Frameworks/QtXml.framework
, which in turn depends on QtCore. But then QtCore is also loaded from the global directory which can lead to all kinds of errors. In my case, the application was hanging indefinitely in the QWebpage constructor. Other people seem to experience crashes. The solution is of course to include and patch all necessary Qt components (via install_name_tool
) in your own application.
UPDATE: After I renamed the global ones to their original name, I'm still experiencing problems because both places are considered. Still trying to resolve that. I'll leave the above answer here just for the record.
Upvotes: 2
Reputation: 4357
I found the issue and will post my answer here if someelse should have the same issue.
I totally forgot about my lib that I was loading durring runtime that was not built using the local frameworks. When I removed the plugin it ran fine and everything is good now :)
Upvotes: 0
Reputation: 92637
I have seen this before when packaging PyQt apps as well. The fix (which is usually done by macdeployqt), is to place a qt.conf
file inside the Contents/Resources
directory of the app. It would just normally contain the name of your plugins directory:
Contents/Resources/qt.conf
[Paths]
Plugins = plugins
This will make it stop trying to look at your system for Qt libs. You shouldn't need the -dmg
flag, as thats unrelated to this situation. I recommend simply running macdeployqt MyApp.app
on a clean build and seeing if it creates the qt.conf for you.
Upvotes: 4