MacOS dylib plugin loading path changes from Qt 5.15 to Qt 6.2
-
Hi,
I'm no longer able to load my Steam plugin with the way it worked in 5.15 on macOS. It does still work on Windows. I created a qml plugin that gets loaded on runtime that needs the libsteam_api.dylib. Previously placing the libsteam_api.dylib beside the plugin worked fine.
// This fixed the plugin loading in 5.15 m_mainWindowEngine->addPluginPath(QGuiApplication::instance()->applicationDirPath()); // Does also not work when adding: m_mainWindowEngine->addPluginPath(QGuiApplication::instance()->applicationDirPath() + "/Workshop");
Now it ony works on macOS when placing the libsteam_api.dylib besides the .app file.
"qrc:/ScreenPlay/qml/Workshop/SteamWorkshop.qml:6:1: Die Bibliothek /Users/eli/Documents/build-ScreenPlay-ScreenPlay_Qt_6_2_1_clang_64bit-Release/bin/ScreenPlay.app/Contents/MacOS/Workshop/libScreenPlayWorkshopplugin.dylib kann nicht geladen werden: (dlopen(/Users/eli/Documents/build-ScreenPlay-ScreenPlay_Qt_6_2_1_clang_64bit-Release/bin/ScreenPlay.app/Contents/MacOS/Workshop/libScreenPlayWorkshopplugin.dylib, 0x0085): Library not loaded: @rpath/libScreenPlayWorkshop.dylib\n Referenced from: /Users/eli/Documents/build-ScreenPlay-ScreenPlay_Qt_6_2_1_clang_64bit-Release/bin/ScreenPlay.app/Contents/MacOS/Workshop/libScreenPlayWorkshopplugin.dylib\n Reason: tried: '/Users/eli/Documents/build-ScreenPlay-ScreenPlay_Qt_6_2_1_clang_64bit-Release/bin/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtQuick.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtQmlModels.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtQml.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtOpenGL.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtGui.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtNetwork.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtCore.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Documents/ScreenPlay-vcpkg/installed/x64-osx/lib/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Documents/build-ScreenPlay-ScreenPlay_Qt_6_2_1_clang_64bit-Release/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtWebSockets.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtSvg.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtWidgets.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtWebEngineQuick.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtWebEngineCore.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtWebChannel.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtPositioning.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Documents/build-ScreenPlay-ScreenPlay_Qt_6_2_1_clang_64bit-Release/bin/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Documents/build-ScreenPlay-ScreenPlay_Qt_6_2_1_clang_64bit-Release/bin/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtCore.framework/Versions/A/../../../libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/libScreenPlayWorkshop.dylib' (no such file), '/usr/local/lib/libScreenPlayWorkshop.dylib' (no such file), '/usr/lib/libScreenPlayWorkshop.dylib' (no such file))"
Repo: https://gitlab.com/kelteseth/ScreenPlay
CMake file: https://gitlab.com/kelteseth/ScreenPlay/-/blob/master/ScreenPlayWorkshop/CMakeLists.txt#L53 -
Hi,
Shouldn't that library be stored in the Frameworks sub folder and then its search path be set to @rpath/../Frameworks ?
-
@SGaist thanks for the anweser, but none of that worked.
m_mainWindowEngine->addPluginPath(QGuiApplication::instance()->applicationDirPath()); m_mainWindowEngine->addPluginPath(QGuiApplication::instance()->applicationDirPath()+"/../Frameworks"); m_mainWindowEngine->addPluginPath("@rpath/../Frameworks"); m_mainWindowEngine->addImportPath("@rpath/../Frameworks"); m_mainWindowEngine->addImportPath(QGuiApplication::instance()->applicationDirPath()); m_mainWindowEngine->addImportPath(QGuiApplication::instance()->applicationDirPath()+"/../Frameworks"); qInfo() << m_mainWindowEngine->pluginPathList(); qInfo() << m_mainWindowEngine->importPathList(); qInfo() << QGuiApplication::instance()->libraryPaths();
printing:
"QList(\"\", \"/Users/eli/Documents/build-ScreenPlay-ScreenPlay_Qt_6_2_1_clang_64bit-Release/bin/ScreenPlay.app/Contents/Frameworks\", \"/Users/eli/Documents/build-ScreenPlay-ScreenPlay_Qt_6_2_1_clang_64bit-Release/bin/ScreenPlay.app/Contents/MacOS\", \".\")" "QList(\"/Users/eli/Documents/build-ScreenPlay-ScreenPlay_Qt_6_2_1_clang_64bit-Release/bin/ScreenPlay.app/Contents/Frameworks\", \"/Users/eli/Documents/build-ScreenPlay-ScreenPlay_Qt_6_2_1_clang_64bit-Release/bin/ScreenPlay.app/Contents/MacOS\", \"qrc:/qt-project.org/imports\", \"/Users/eli/Qt/6.2.1/macos/qml\")" "QList(\"/Users/eli/Qt/6.2.1/macos/plugins\", \"/Users/eli/Documents/build-ScreenPlay-ScreenPlay_Qt_6_2_1_clang_64bit-Release/bin/ScreenPlay.app/Contents/MacOS\")"
I now copied the files in every folder like:
- /ScreenPlay.app/Contents/MacOS\
- /ScreenPlay.app/Contents/MacOS\Workshop
- /ScreenPlay.app/Contents/Framworks\Workshop
It only works if I place the third party dylib besides ScreenPlay.app location. This is only since my upgrade to Qt 6.2
Content of the Workshop folder:
ScreenPlayWorkshop.qmltypes libScreenPlayWorkshop.dylib libScreenPlayWorkshopplugin.dylib libsteam_api.dylib # <- Only works if this file is in the same folder as ScreenPlay.app libScreenPlayWorkshopplugin.a libSteamSDK.a qmldir
When loading the qml plugin:
"qrc:/ScreenPlay/qml/Workshop/SteamWorkshop.qml:6:1: Die Bibliothek /Users/eli/Documents/build-ScreenPlay-ScreenPlay_Qt_6_2_1_clang_64bit-Release/bin/ScreenPlay.app/Contents/MacOS/Workshop/libScreenPlayWorkshopplugin.dylib kann nicht geladen werden: (dlopen(/Users/eli/Documents/build-ScreenPlay-ScreenPlay_Qt_6_2_1_clang_64bit-Release/bin/ScreenPlay.app/Contents/MacOS/Workshop/libScreenPlayWorkshopplugin.dylib, 0x0085): Library not loaded: @rpath/libScreenPlayWorkshop.dylib\n Referenced from: /Users/eli/Documents/build-ScreenPlay-ScreenPlay_Qt_6_2_1_clang_64bit-Release/bin/ScreenPlay.app/Contents/MacOS/Workshop/libScreenPlayWorkshopplugin.dylib\n Reason: tried: '/Users/eli/Documents/build-ScreenPlay-ScreenPlay_Qt_6_2_1_clang_64bit-Release/bin/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtQuick.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtQmlModels.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtQml.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtOpenGL.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtGui.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtNetwork.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtCore.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Documents/ScreenPlay-vcpkg/installed/x64-osx/lib/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Documents/build-ScreenPlay-ScreenPlay_Qt_6_2_1_clang_64bit-Release/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtWebSockets.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtSvg.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtWidgets.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtWebEngineQuick.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtWebEngineCore.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtWebChannel.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtPositioning.framework/Versions/A/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Documents/build-ScreenPlay-ScreenPlay_Qt_6_2_1_clang_64bit-Release/bin/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Documents/build-ScreenPlay-ScreenPlay_Qt_6_2_1_clang_64bit-Release/bin/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/QtCore.framework/Versions/A/../../../libScreenPlayWorkshop.dylib' (no such file), '/Users/eli/Qt/6.2.1/macos/lib/libScreenPlayWorkshop.dylib' (no such file), '/usr/local/lib/libScreenPlayWorkshop.dylib' (no such file), '/usr/lib/libScreenPlayWorkshop.dylib' (no such file))"
-
Did you use macdeployqt on your app bundle ?
-
@QKelteseth in the terminal, please navigate inside your bundle where the main executable resides (ScreenPlay.app/Contents/MacOS) and run
otool -L <your_exe_name>
- this will print you what shared libraries are linked to that executable and where do they are expected.You should run macdeployqt also when using qml (if in doubt run
macdeployqt --help
).if you need to adjust linked paths in your executable in the macOS folder of your bundle then the tool
install_name_tool
is your friend. -
@QKelteseth said in MacOS dylib plugin loading path changes from Qt 5.15 to Qt 6.2:
@SGaist isn't macdeployqt only for qt libraries?
It is to be used when you want to prepare your app bundle for deployment.
-
@artwaw @SGaist I think it works now if I place it in the root Frameworks folder. Using ottol on the lib printed:
Load command 12 cmd LC_LOAD_DYLIB cmdsize 56 name @loader_path/libsteam_api.dylib (offset 24) time stamp 2 Thu Jan 1 01:00:02 1970 current version 1.0.0 compatibility version 1.0.0 Load command 13 cmd LC_LOAD_DYLIB cmdsize 72 name @rpath/QtQuick.framework/Versions/A/QtQuick (offset 24) time stamp 2 Thu Jan 1 01:00:02 1970 current version 6.2.1 compatibility version 6.0.0 Load command 14
Thanks for your help! Have a great weekend <3