Building on OSX Catalina and deploying on Monterey with dynamic libs
-
Hi community,
I'm building a minimal Qt6.4 app on Catalina and using
macdeployqt
to deploy a bundle. While the app runs perfectly well on another computer running Catalina without Qt installed, when I open the app on a system running Monterey, I get the error: "The application 'Template' can't be opened".Here are the details:
Tested on: OSX 12.6
Built on: OSX 10.15.4
Xcode version: 12.4
OSX SDK version: 11.1
Qt version: 6.4.0src/main.cpp
:#include <QtWidgets> int main(int argc, char **argv) { QApplication app(argc, argv); QMainWindow mainWindow; mainWindow.show(); return app.exec(); }
Template.pro
:QT += widgets CONFIG += c++17 SOURCES += src/main.cpp
I first build a release version in QtCreator and then I run:
~/Qt/6.4.0/macos/bin/macdeployqt Template.app
which I can see has put Qt's frameworks in the bundle.
Running
otool -L Template.app/Contents/MacOS/Template
gives me:Template.app/Contents/MacOS/Template: @rpath/QtWidgets.framework/Versions/A/QtWidgets (compatibility version 6.0.0, current version 6.4.0) @rpath/QtGui.framework/Versions/A/QtGui (compatibility version 6.0.0, current version 6.4.0) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2022.20.117) /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/Metal.framework/Versions/A/Metal (compatibility version 1.0.0, current version 244.32.7) @rpath/QtCore.framework/Versions/A/QtCore (compatibility version 6.0.0, current version 6.4.0) /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0) /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (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) /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 904.4.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)
What am I missing? Has anyone had any success building on Catalina and running on Monterey?
-
I've managed to deploy a test app from Monterey which works on Catalina and Monterey and given up on building on Catalina after spending a few days trying to fix the result of
macdeployqt
usingotool
andinstall_name_tool
.It seems that the CMake
qt_generate_deploy_app_script
method doesn't work when run from Monterey either. Running themacdeployqt
utility almost works out of the box, it just leaves the plugins' RPATH pointing to a nonexistent 'lib' folder where it expects Qt frameworks to be. Rather than fix the RPATH's in each of those plugin libs, adding a 'lib' symlink pointing to the Frameworks folder seems to do the trick.In case it's useful to anyone, I've made a template repository on GitHub with this solution. The template allows you to deploy apps with LGPL Qt on Mac and Windows and use VSCode as an IDE rather than QtCreator: