Hi everyone,
I succeeded in building my application (with two shared libs, one of them QWT) into a framework using Qt Creator on my Mac (Mac OS X 10.5)
When running the macdeployqt tool I get two warning messages that the tool cannot find my dylib files, but apart from that the Framework is created ok.
(There seems to be a bug in the script though, because if I don't create the directory myapp.app/Contents/translations first, the script will just copy the system translation file into this file, but not into the directory).
So far so good. Now I copy my own dylib files into the Frameworks directory and create the library links manually as described in the Qt Deployment documentation. This allows me to run the application, but during startup I get the information that multiple libraries are found and the ones in the Frameworks directory are used. Ok. But then the app crashes ("QWidget: Must construct a QApplication before a QPaintDevice").
The strange thing is that when I remove the Qt-Framework packages from the Frameworks directory, the application runs fine - this time using the qt libraries in the system path.
What am I doing wrong? Or is this generally a problem that you cannot run Qt apps with Qt Frameworks in the bundle when you have Qt Development tools also installed?
Thanks for any help. Also, is there a flag or trick how I can get macdeployqt to find my own dylib files and put them into the Framework automatically?
--- Detailed information on the Deployment procedure ---
1. After building my application I find the following file and directory structure:
$ ls -R RoomModel.app
Contents
RoomModel.app/Contents:
Info.plist MacOS PkgInfo Resources
RoomModel.app/Contents/MacOS:
RoomModel
RoomModel.app/Contents/Resources:
empty.lproj
$ ls -R RoomModel.app
Contents
RoomModel.app/Contents:
Info.plist MacOS PkgInfo Resources
RoomModel.app/Contents/MacOS:
RoomModel
RoomModel.app/Contents/Resources:
empty.lproj
To copy to clipboard, switch view to plain text mode
2. Running otool gives
$ otool -L RoomModel.app/Contents/MacOS/RoomModel
RoomModel.app/Contents/MacOS/RoomModel:
libRoomModel.1.dylib (compatibility version 1.0.0, current version 1.0.0)
libqwt.5.dylib (compatibility version 5.2.0, current version 5.2.1)
QtSvg.framework/Versions/4/QtSvg (compatibility version 4.5.0, current version 4.5.2)
QtGui.framework/Versions/4/QtGui (compatibility version 4.5.0, current version 4.5.2)
/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 136.0.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 949.54.0)
QtCore.framework/Versions/4/QtCore (compatibility version 4.5.0, current version 4.5.2)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
$ otool -L RoomModel.app/Contents/MacOS/RoomModel
RoomModel.app/Contents/MacOS/RoomModel:
libRoomModel.1.dylib (compatibility version 1.0.0, current version 1.0.0)
libqwt.5.dylib (compatibility version 5.2.0, current version 5.2.1)
QtSvg.framework/Versions/4/QtSvg (compatibility version 4.5.0, current version 4.5.2)
QtGui.framework/Versions/4/QtGui (compatibility version 4.5.0, current version 4.5.2)
/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 136.0.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 949.54.0)
QtCore.framework/Versions/4/QtCore (compatibility version 4.5.0, current version 4.5.2)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
To copy to clipboard, switch view to plain text mode
3. Now I need to create the translations subdir manually
$ mkdir RoomModel.app/Contents/translations
$ mkdir RoomModel.app/Contents/translations
To copy to clipboard, switch view to plain text mode
4. I run macdeployqt
$ macdeployqt RoomModel.app -no-plugins
ERROR: no file at "/usr/lib/libRoomModel.1.dylib"
ERROR: no file at "/usr/lib/libqwt.5.dylib"
copied "/Library/Frameworks/QtSvg.framework/Versions/4/QtSvg" to "RoomModel.app/Contents/Frameworks/QtSvg.framework/Versions/4/QtSvg"
stripped "RoomModel.app/Contents/Frameworks/QtSvg.framework/Versions/4/QtSvg"
copied "/Library/Frameworks/QtGui.framework/Versions/4/QtGui" to "RoomModel.app/Contents/Frameworks/QtGui.framework/Versions/4/QtGui"
copied "/Library/Frameworks/QtGui.framework/Resources/qt_menu.nib/classes.nib" to "RoomModel.app/Contents/Frameworks/QtGui.framework/Resources/qt_menu.nib/classes.nib"
copied "/Library/Frameworks/QtGui.framework/Resources/qt_menu.nib/info.nib" to "RoomModel.app/Contents/Frameworks/QtGui.framework/Resources/qt_menu.nib/info.nib"
copied "/Library/Frameworks/QtGui.framework/Resources/qt_menu.nib/keyedobjects.nib" to "RoomModel.app/Contents/Frameworks/QtGui.framework/Resources/qt_menu.nib/keyedobjects.nib"
stripped "RoomModel.app/Contents/Frameworks/QtGui.framework/Versions/4/QtGui"
copied "/Library/Frameworks/QtCore.framework/Versions/4/QtCore" to "RoomModel.app/Contents/Frameworks/QtCore.framework/Versions/4/QtCore"
stripped "RoomModel.app/Contents/Frameworks/QtCore.framework/Versions/4/QtCore"
$ macdeployqt RoomModel.app -no-plugins
ERROR: no file at "/usr/lib/libRoomModel.1.dylib"
ERROR: no file at "/usr/lib/libqwt.5.dylib"
copied "/Library/Frameworks/QtSvg.framework/Versions/4/QtSvg" to "RoomModel.app/Contents/Frameworks/QtSvg.framework/Versions/4/QtSvg"
stripped "RoomModel.app/Contents/Frameworks/QtSvg.framework/Versions/4/QtSvg"
copied "/Library/Frameworks/QtGui.framework/Versions/4/QtGui" to "RoomModel.app/Contents/Frameworks/QtGui.framework/Versions/4/QtGui"
copied "/Library/Frameworks/QtGui.framework/Resources/qt_menu.nib/classes.nib" to "RoomModel.app/Contents/Frameworks/QtGui.framework/Resources/qt_menu.nib/classes.nib"
copied "/Library/Frameworks/QtGui.framework/Resources/qt_menu.nib/info.nib" to "RoomModel.app/Contents/Frameworks/QtGui.framework/Resources/qt_menu.nib/info.nib"
copied "/Library/Frameworks/QtGui.framework/Resources/qt_menu.nib/keyedobjects.nib" to "RoomModel.app/Contents/Frameworks/QtGui.framework/Resources/qt_menu.nib/keyedobjects.nib"
stripped "RoomModel.app/Contents/Frameworks/QtGui.framework/Versions/4/QtGui"
copied "/Library/Frameworks/QtCore.framework/Versions/4/QtCore" to "RoomModel.app/Contents/Frameworks/QtCore.framework/Versions/4/QtCore"
stripped "RoomModel.app/Contents/Frameworks/QtCore.framework/Versions/4/QtCore"
To copy to clipboard, switch view to plain text mode
How can I tell macdeployqt where my dylib files are?
5. when running the app now, I get:
$ RoomModel.app/Contents/MacOS/RoomModel
dyld: Library not loaded: @executable_path/../Frameworks/libRoomModel.1.dylib
Referenced from: /Users/xxx/Documents/room_model/bin/RoomModel.app/Contents/MacOS/RoomModel
Reason: image not found
Trace/BPT trap
$ RoomModel.app/Contents/MacOS/RoomModel
dyld: Library not loaded: @executable_path/../Frameworks/libRoomModel.1.dylib
Referenced from: /Users/xxx/Documents/room_model/bin/RoomModel.app/Contents/MacOS/RoomModel
Reason: image not found
Trace/BPT trap
To copy to clipboard, switch view to plain text mode
so I copy the dynamic libraries into the Frameworks directory.
$ cp ../src/libs/libRoomModel.1.dylib RoomModel.app/Contents/Frameworks/
$ cp ../externals/qwt/lib/libqwt.5.dylib RoomModel.app/Contents/Frameworks/
$ cp ../src/libs/libRoomModel.1.dylib RoomModel.app/Contents/Frameworks/
$ cp ../externals/qwt/lib/libqwt.5.dylib RoomModel.app/Contents/Frameworks/
To copy to clipboard, switch view to plain text mode
6. Running otool again:
@executable_path/../Frameworks/libRoomModel.1.dylib (compatibility version 1.0.0, current version 1.0.0)
@executable_path/../Frameworks/libqwt.5.dylib (compatibility version 5.2.0, current version 5.2.1)
@executable_path/../Frameworks/QtSvg.framework/Versions/4/QtSvg (compatibility version 4.5.0, current version 4.5.2)
@executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui (compatibility version 4.5.0, current version 4.5.2)
/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 136.0.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 949.54.0)
@executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore (compatibility version 4.5.0, current version 4.5.2)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
@executable_path/../Frameworks/libRoomModel.1.dylib (compatibility version 1.0.0, current version 1.0.0)
@executable_path/../Frameworks/libqwt.5.dylib (compatibility version 5.2.0, current version 5.2.1)
@executable_path/../Frameworks/QtSvg.framework/Versions/4/QtSvg (compatibility version 4.5.0, current version 4.5.2)
@executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui (compatibility version 4.5.0, current version 4.5.2)
/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 136.0.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 949.54.0)
@executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore (compatibility version 4.5.0, current version 4.5.2)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
To copy to clipboard, switch view to plain text mode
All custom libraries are linked in the Frameworks directory, as it should be.
7. Now running should work:
$ RoomModel.app/Contents/MacOS/RoomModel
objc[4049]: Class QCocoaColorPanelDelegate is implemented in both /Library/Frameworks/QtGui.framework/Versions/4/QtGui and
/Users/xxx/Documents/room_model/bin/RoomModel.app/Contents/MacOS/../Frameworks/QtGui.framework/Versions/4/QtGui.
Using implementation from /Users/xxx/Documents/room_model/bin/RoomModel.app/Contents/MacOS/../Frameworks/QtGui.framework/Versions/4/QtGui.
(... many more of these double implementations)
Abort trap
$ RoomModel.app/Contents/MacOS/RoomModel
objc[4049]: Class QCocoaColorPanelDelegate is implemented in both /Library/Frameworks/QtGui.framework/Versions/4/QtGui and
/Users/xxx/Documents/room_model/bin/RoomModel.app/Contents/MacOS/../Frameworks/QtGui.framework/Versions/4/QtGui.
Using implementation from /Users/xxx/Documents/room_model/bin/RoomModel.app/Contents/MacOS/../Frameworks/QtGui.framework/Versions/4/QtGui.
(... many more of these double implementations)
QWidget: Must construct a QApplication before a QPaintDevice
Abort trap
To copy to clipboard, switch view to plain text mode
I can't seem to find the problem with the QWidget and the QPaintDevice.
8. Manually deleting the Qt frameworks from the bundle
$ rm -r RoomModel.app/Contents/Frameworks/QtCore.framework/
$ rm -r RoomModel.app/Contents/Frameworks/QtGui.framework/
$ rm -r RoomModel.app/Contents/Frameworks/QtSvg.framework/
$ rm -r RoomModel.app/Contents/Frameworks/QtCore.framework/
$ rm -r RoomModel.app/Contents/Frameworks/QtGui.framework/
$ rm -r RoomModel.app/Contents/Frameworks/QtSvg.framework/
To copy to clipboard, switch view to plain text mode
running: now it runs perfectly inside the bundle.
What is the problem with the frameworks here???
--- End Detailed information on the Deployment procedure ---
Bookmarks