Added QMysql plugin to Qt Creator project on MacOS Ventura 13.4
-
Which error are you getting now ?
-
Did you ensure that the plugin was put in the plugins folder ? Did you build it for both debug and release ? Did you copy both variants to the appropriate subfolder ?
-
As already requested, stop working in the installation tree, create the build dir completely outside of it.
Start your application with the
QT_DEBUG_PLUGINS
environment variable set to 1 to see what is happening with the plugins. -
@SGaist Ok sorry. I delete build-sqldrivers from Qt directory and build one more time on my desktop. I input QT_DEBUG_PLUGINS in my code and I got this:
qt.core.plugin.factoryloader: checking directory path "/Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/platforms" ... qt.core.plugin.factoryloader: looking at "/Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/platforms/libqoffscreen.dylib" qt.core.plugin.loader: Found metadata in lib /Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/platforms/libqoffscreen.dylib, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "offscreen" ] }, "archlevel": 0, "className": "QOffscreenIntegrationPlugin", "debug": false, "version": 394496 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("offscreen") qt.core.plugin.factoryloader: looking at "/Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/platforms/libqminimal.dylib" qt.core.plugin.loader: Found metadata in lib /Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/platforms/libqminimal.dylib, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "minimal" ] }, "archlevel": 0, "className": "QMinimalIntegrationPlugin", "debug": false, "version": 394496 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("minimal") qt.core.plugin.factoryloader: looking at "/Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/platforms/libqcocoa.dylib" qt.core.plugin.loader: Found metadata in lib /Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/platforms/libqcocoa.dylib, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "cocoa" ] }, "archlevel": 0, "className": "QCocoaIntegrationPlugin", "debug": false, "version": 394496 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("cocoa") qt.core.plugin.factoryloader: checking directory path "/Users/mikolajnawrocki/Documents/GitHub/build-ATLAS-Qt_6_5_0_for_macOS-Release/platforms" ... qt.core.library: "/Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/platforms/libqcocoa.dylib" loaded library qt.core.plugin.factoryloader: checking directory path "/Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/platformthemes" ... qt.core.plugin.factoryloader: checking directory path "/Users/mikolajnawrocki/Documents/GitHub/build-ATLAS-Qt_6_5_0_for_macOS-Release/platformthemes" ... qt.core.plugin.factoryloader: checking directory path "/Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/styles" ... qt.core.plugin.factoryloader: looking at "/Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/styles/libqmacstyle.dylib" qt.core.plugin.loader: Found metadata in lib /Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/styles/libqmacstyle.dylib, metadata= { "IID": "org.qt-project.Qt.QStyleFactoryInterface", "MetaData": { "Keys": [ "macOS" ] }, "archlevel": 0, "className": "QMacStylePlugin", "debug": false, "version": 394496 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("macos") qt.core.plugin.factoryloader: checking directory path "/Users/mikolajnawrocki/Documents/GitHub/build-ATLAS-Qt_6_5_0_for_macOS-Release/styles" ... qt.core.library: "/Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/styles/libqmacstyle.dylib" loaded library qt.qpa.fonts: Populating font family aliases took 50 ms. Replace uses of missing font family "Roboto" with one that exists to avoid this cost. qt.core.plugin.factoryloader: checking directory path "/Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/networkaccess" ... qt.core.plugin.factoryloader: checking directory path "/Users/mikolajnawrocki/Documents/GitHub/build-ATLAS-Qt_6_5_0_for_macOS-Release/networkaccess" ... qt.core.library: "resolv" loaded library qt.core.plugin.factoryloader: checking directory path "/Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/sqldrivers" ... qt.core.plugin.factoryloader: looking at "/Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/sqldrivers/libqsqlite.dylib" qt.core.plugin.loader: Found metadata in lib /Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/sqldrivers/libqsqlite.dylib, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QSQLITE" ] }, "archlevel": 0, "className": "QSQLiteDriverPlugin", "debug": false, "version": 394496 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QSQLITE") qt.core.plugin.factoryloader: looking at "/Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/sqldrivers/libqsqlmysql.dylib" qt.core.plugin.loader: Failed to find metadata in lib /Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/sqldrivers/libqsqlmysql.dylib: '/Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/sqldrivers/libqsqlmysql.dylib' is not a valid Mach-O binary (wrong architecture) qt.core.plugin.factoryloader: "Failed to extract plugin meta data from '/Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/sqldrivers/libqsqlmysql.dylib': '/Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/sqldrivers/libqsqlmysql.dylib' is not a valid Mach-O binary (wrong architecture)" not a plugin qt.core.plugin.factoryloader: looking at "/Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/sqldrivers/libqsqlodbc.dylib" qt.core.plugin.loader: Found metadata in lib /Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/sqldrivers/libqsqlodbc.dylib, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QODBC" ] }, "archlevel": 0, "className": "QODBCDriverPlugin", "debug": false, "version": 394496 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QODBC") qt.core.plugin.factoryloader: looking at "/Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/sqldrivers/libqsqlpsql.dylib" qt.core.plugin.loader: Found metadata in lib /Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/sqldrivers/libqsqlpsql.dylib, metadata= { "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface", "MetaData": { "Keys": [ "QPSQL" ] }, "archlevel": 0, "className": "QPSQLDriverPlugin", "debug": false, "version": 394496 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QPSQL") qt.core.plugin.factoryloader: checking directory path "/Users/mikolajnawrocki/Documents/GitHub/build-ATLAS-Qt_6_5_0_for_macOS-Release/sqldrivers" ... QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QODBC QPSQL qt.core.plugin.factoryloader: checking directory path "/Users/mikolajnawrocki/Qt/6.5.0/macos/plugins/accessible" ... qt.core.plugin.factoryloader: checking directory path "/Users/mikolajnawrocki/Documents/GitHub/build-ATLAS-Qt_6_5_0_for_macOS-Release/accessible" ...
-
@BushyAxis793 check the file type and architecture of the plugin you created. There's something wrong with it.
-
@SGaist OK. I decided to delete and build plugin one more time and I still got no errors but I noticed few warnings:
ld: warning: dylib (/usr/local/mysql/lib/libmysqlclient.dylib) was built for newer macOS version (12.0) than being linked (11.0) ld: warning: linking against a dylib which is not safe for use in application extensions: /usr/local/mysql/lib/libmysqlclient.dylib
The file type of my libmysqlclient.dylib seems be ok and the architecture is universal (x86 + amr64) via lipo.
-
What about
libqsqlmysql.dylib
? -
@SGaist I checked libqsqlmysql.dylib architecture:
mikolajnawrocki@MacBook-Pro-Mikoaj ~ % lipo -info /Users/mikolajnawrocki/Desktop/build-sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib Non-fat file: /Users/mikolajnawrocki/Desktop/build-sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib is architecture: x86_64
-
Looks like it still is single architecture.
-
@SGaist As I said before libmysqlclient.dylib is universal
mikolajnawrocki@MacBook-Pro-Mikoaj ~ % lipo -info /Users/mikolajnawrocki/Desktop/universal/libmysqlclient.dylib Architectures in the fat file: /Users/mikolajnawrocki/Desktop/universal/libmysqlclient.dylib are: x86_64 arm64
So the question is why libqsqlmysql.dylib is still x86?
in this command
/Users/mikolajnawrocki/Qt/6.5.0/macos/bin/qt-cmake /Users/mikolajnawrocki/Qt/6.5.0/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=/Users/mikolajnawrocki/Qt/6.5.0/macos -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.dylib"
libmysqlclient.dylib has correctly architecture
Maybe something with this warnings?
ld: warning: dylib (/usr/local/mysql/lib/libmysqlclient.dylib) was built for newer macOS version (12.0) than being linked (11.0) ld: warning: linking against a dylib which is not safe for use in application extensions: /usr/local/mysql/lib/libmysqlclient.dylib
I think I am very close to fix my problem but still needs some help.
-
Hi, to be sure you build for the correct architecture, you can specify it on qt-cmake's command line, like this:
/Users/mikolajnawrocki/Qt/6.5.0/macos/bin/qt-cmake /Users/mikolajnawrocki/Qt/6.5.0/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=/Users/mikolajnawrocki/Qt/6.5.0/macos -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.dylib" -DCMAKE_OSX_ARCHITECTURES="arm64" .
-
@hskoglund Thanks for reply. I was follow your tip and the architecture is:
mikolajnawrocki@MacBook-Pro-Mikoaj ~ % lipo -info /Users/mikolajnawrocki/Desktop/build-sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib Non-fat file: /Users/mikolajnawrocki/Desktop/build-sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib is architecture: x86_64
-
@hskoglund I know but my architecture is x86_64/arm64 so I need universal plugin. No idea how to install arm only version of QT.
-
@hskoglund OK. So, can You tell me what is in you opinion best way to add qmysql plugin to qt creator?
-
If you do that qt-cmake command again with the architecture specified (same as I posted 7 hours ago):
/Users/mikolajnawrocki/Qt/6.5.0/macos/bin/qt-cmake ... -DCMAKE_OSX_ARCHITECTURES="arm64"
and then try the lipo command:
lipo -info /Users/mikolajnawrocki/Desktop/build-sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib
if it still says "x86_64" then try nuking the build directory :-)