MYSQL plugin on M1 Mac?
-
Good afternoon
This is my very first post, and I hope it's the appropriate place.
Tried to compile the MYSQL plugin for Qt 6.3 on a 2021 M1 Max MacBook Pro as of May 2, 2022.
I used CMake 3.21.1 and Ninja 1.10.2 that comes with Qt (as well as CMake 3.23.1 from cmake.org), and followed https://doc.qt.io/qt-6/sql-driver.html where it says:
Configuration is fine, but then the build fails as it compiles for x86_64 instead of macOS-arm64:
I would very much appreciate any idea / hint / solution for the problem, thanks...
-
Hi, for being your first post you have a bit of luck :-) What I mean more or less the same problem was discussed 2 months ago
So try again, first erase all the build files/caches so you have new, clean build enviroment and then try adding this at the end of the qt-cmake command line:
-DCMAKE_OSX_ARCHITECTURES="arm64" -
First of all thank you for your answer, and sorry for the long delay of my feedback but I'm somewhat busy and programming is not my main professional activity...
Anyhow, I'm still not able to compile the SQL plugin. I followed of course your advice and what was outlined in your other answer you indicated. I removed Qt and the build directory, did a fresh install of Qt and:
chriam: ~/Development/build-sqldrivers % /Users/chriam/Qt/6.3.1/macos/bin/qt-cmake -G Ninja /Users/chriam/Qt/6.3.1/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=/Users/chriam/Qt/6.3.1/macos -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.dylib" -DCMAKE_OSX_ARCHITECTURES="arm64" -- The CXX compiler identification is AppleClang 13.1.6.13160021 -- The C compiler identification is AppleClang 13.1.6.13160021 -- The ASM compiler identification is Clang with GNU-like command-line -- Found assembler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/clang++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/clang - skipped -- Detecting C compile features -- Detecting C compile features - done -- Looking for pthread.h -- Looking for pthread.h - found -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE -- Performing Test HAVE_STDATOMIC -- Performing Test HAVE_STDATOMIC - Success -- Found WrapAtomic: TRUE -- Configuration summary has been written to /Users/chriam/Development/build-sqldrivers/config.summary -- Configure with --log-level=STATUS or higher to increase the output verbosity. -- Configuring done -- Generating done -- Build files have been written to: /Users/chriam/Development/build-sqldrivers
(I tried both with and without the architecture specification DCMAKE_OSX_ARCHITECTURES="arm64", as you suggested that it does work for building the sqllite and odbc plugins but not for mysql.)
Now I cannot find any link.txt file (the QMYSQLDriverPlugin.dir is essentially empty, and neither in the build directory nor in the ~/Qt directory does exist a link.txt):
chriam: ~/Development/build-sqldrivers % find /Users/chriam/Development/build-sqldrivers -name link.txt chriam: ~/Development/build-sqldrivers % find /Users/chriam/Qt -name link.txtchriam: ~/Development/build-sqldrivers % cd ~/Qt/6.3.1/Src/qtbase/src/plugins/sqldrivers/mysql/CMakeFiles/QMYSQLDriverPlugin.dir chriam: ~/Qt/6.3.1/Src/qtbase/src/plugins/sqldrivers/mysql/CMakeFiles/QMYSQLDriverPlugin.dir % ls -al total 0 drwxr-xr-x 3 chriam staff 96 Aug 2 18:07 . drwxr-xr-x 5 chriam staff 160 Aug 2 18:07 .. drwxr-xr-x 2 chriam staff 64 Aug 2 18:07 QMYSQLDriverPlugin_autogen chriam: ~/Qt/6.3.1/Src/qtbase/src/plugins/sqldrivers/mysql/CMakeFiles/QMYSQLDriverPlugin.dir % ls QMYSQLDriverPlugin_autogen chriam: ~/Qt/6.3.1/Src/qtbase/src/plugins/sqldrivers/mysql/CMakeFiles/QMYSQLDriverPlugin.dir %
If I do the build, it fails of course as before due to the architecture mismatch:
chriam: ~/Development/build-sqldrivers % cmake --build . [0/1] Re-running CMake... -- Configuring done -- Generating done -- Build files have been written to: /Users/chriam/Development/build-sqldrivers [8/11] Linking CXX shared module plugins/sqldrivers/libqsqlmysql.dylib FAILED: plugins/sqldrivers/libqsqlmysql.dylib : && /usr/bin/clang++ -g -DNDEBUG -O2 -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -mmacosx-version-min=10.14 -bundle -Wl,-headerpad_max_install_names -Wl,-undefined,error -fapplication-extension -o plugins/sqldrivers/libqsqlmysql.dylib mysql/CMakeFiles/QMYSQLDriverPlugin.dir/QMYSQLDriverPlugin_autogen/mocs_compilation.cpp.o mysql/CMakeFiles/QMYSQLDriverPlugin.dir/main.cpp.o mysql/CMakeFiles/QMYSQLDriverPlugin.dir/qsql_mysql.cpp.o -Wl,-rpath,/usr/local/mysql/lib -Wl,-rpath,/Users/chriam/Qt/6.3.1/macos/lib /usr/local/mysql/lib/libmysqlclient.dylib /Users/chriam/Qt/6.3.1/macos/lib/QtSql.framework/Versions/A/QtSql /Users/chriam/Qt/6.3.1/macos/lib/QtCore.framework/Versions/A/QtCore -framework DiskArbitration -framework IOKit && cd /Users/chriam/Development/build-sqldrivers/mysql && /Users/chriam/Qt/Tools/CMake/CMake.app/Contents/bin/cmake -E make_directory /Users/chriam/Development/build-sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib.dSYM/Contents/Resources/DWARF && /Users/chriam/Qt/Tools/CMake/CMake.app/Contents/bin/cmake -E copy Info.dSYM.plist /Users/chriam/Development/build-sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib.dSYM/Contents/Info.plist && /usr/bin/dsymutil /Users/chriam/Development/build-sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib --flat -o /Users/chriam/Development/build-sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib.dSYM/Contents/Resources/DWARF/qsqlmysql && /usr/bin/strip -S /Users/chriam/Development/build-sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib && chmod -x /Users/chriam/Development/build-sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib.dSYM/Contents/Resources/DWARF/qsqlmysql ld: warning: ignoring file /usr/local/mysql/lib/libmysqlclient.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 Undefined symbols for architecture x86_64: "_mysql_affected_rows", referenced from: QMYSQLResult::reset(QString const&) in qsql_mysql.cpp.o QMYSQLResult::nextResult() in qsql_mysql.cpp.o "_mysql_character_set_name", referenced from: QMYSQLDriver::open(QString const&, QString const&, QString const&, QString const&, int, QString const&) (.cold.1) in qsql_mysql.cpp.o "_mysql_close", referenced from: QMYSQLDriver::open(QString const&, QString const&, QString const&, QString const&, int, QString const&) in qsql_mysql.cpp.o QMYSQLDriver::close() in qsql_mysql.cpp.o "_mysql_data_seek", referenced from: QMYSQLResult::fetch(int) in qsql_mysql.cpp.o "_mysql_errno", referenced from: qMakeError(QString const&, QSqlError::ErrorType, QMYSQLDriverPrivate const*) in qsql_mysql.cpp.o QMYSQLResult::record() const in qsql_mysql.cpp.o "_mysql_error", referenced from: qMakeError(QString const&, QSqlError::ErrorType, QMYSQLDriverPrivate const*) in qsql_mysql.cpp.o QMYSQLDriver::open(QString const&, QString const&, QString const&, QString const&, int, QString const&) (.cold.1) in qsql_mysql.cpp.o "_mysql_fetch_field", referenced from: QMYSQLResultPrivate::bindInValues() in qsql_mysql.cpp.o QMYSQLResult::record() const in qsql_mysql.cpp.o QMYSQLDriver::record(QString const&) const in qsql_mysql.cpp.o "_mysql_fetch_field_direct", referenced from: QMYSQLResult::reset(QString const&) in qsql_mysql.cpp.o QMYSQLResult::nextResult() in qsql_mysql.cpp.o "_mysql_fetch_lengths", referenced from: QMYSQLResult::data(int) in qsql_mysql.cpp.o "_mysql_fetch_row", referenced from: QMYSQLResult::fetch(int) in qsql_mysql.cpp.o QMYSQLResult::fetchNext() in qsql_mysql.cpp.o "_mysql_field_count", referenced from: QMYSQLResult::reset(QString const&) in qsql_mysql.cpp.o QMYSQLResult::nextResult() in qsql_mysql.cpp.o "_mysql_field_seek", referenced from: QMYSQLResult::record() const in qsql_mysql.cpp.o "_mysql_free_result", referenced from: QMYSQLResult::cleanup() in qsql_mysql.cpp.o QMYSQLResult::nextResult() in qsql_mysql.cpp.o QMYSQLDriver::record(QString const&) const in qsql_mysql.cpp.o "_mysql_init", referenced from: QMYSQLDriver::open(QString const&, QString const&, QString const&, QString const&, int, QString const&) in qsql_mysql.cpp.o "_mysql_insert_id", referenced from: QMYSQLResult::lastInsertId() const in qsql_mysql.cpp.o "_mysql_list_fields", referenced from: QMYSQLDriver::record(QString const&) const in qsql_mysql.cpp.o "_mysql_next_result", referenced from: QMYSQLResult::cleanup() in qsql_mysql.cpp.o QMYSQLResult::nextResult() in qsql_mysql.cpp.o "_mysql_num_fields", referenced from: QMYSQLResultPrivate::bindInValues() in qsql_mysql.cpp.o "_mysql_num_rows", referenced from: QMYSQLResult::fetchLast() in qsql_mysql.cpp.o QMYSQLResult::size() in qsql_mysql.cpp.o "_mysql_options", referenced from: QMYSQLDriver::open(QString const&, QString const&, QString const&, QString const&, int, QString const&) in qsql_mysql.cpp.o "_mysql_query", referenced from: QMYSQLDriver::beginTransaction() in qsql_mysql.cpp.o QMYSQLDriver::commitTransaction() in qsql_mysql.cpp.o QMYSQLDriver::rollbackTransaction() in qsql_mysql.cpp.o "_mysql_real_connect", referenced from: QMYSQLDriver::open(QString const&, QString const&, QString const&, QString const&, int, QString const&) in qsql_mysql.cpp.o "_mysql_real_escape_string", referenced from: QMYSQLDriver::formatValue(QSqlField const&, bool) const in qsql_mysql.cpp.o "_mysql_real_query", referenced from: QMYSQLResult::reset(QString const&) in qsql_mysql.cpp.o "_mysql_select_db", referenced from: QMYSQLDriver::open(QString const&, QString const&, QString const&, QString const&, int, QString const&) in qsql_mysql.cpp.o "_mysql_server_end", referenced from: QMYSQLDriver::~QMYSQLDriver() in qsql_mysql.cpp.o QMYSQLDriver::~QMYSQLDriver() in qsql_mysql.cpp.o QMYSQLDriver::~QMYSQLDriver() in qsql_mysql.cpp.o "_mysql_server_init", referenced from: QMYSQLDriver::QMYSQLDriver(QObject*) in qsql_mysql.cpp.o QMYSQLDriver::QMYSQLDriver(MYSQL*, QObject*) in qsql_mysql.cpp.o "_mysql_set_character_set", referenced from: QMYSQLDriver::open(QString const&, QString const&, QString const&, QString const&, int, QString const&) in qsql_mysql.cpp.o "_mysql_ssl_set", referenced from: QMYSQLDriver::open(QString const&, QString const&, QString const&, QString const&, int, QString const&) in qsql_mysql.cpp.o "_mysql_stmt_affected_rows", referenced from: QMYSQLResult::exec() in qsql_mysql.cpp.o "_mysql_stmt_attr_set", referenced from: QMYSQLResult::exec() in qsql_mysql.cpp.o "_mysql_stmt_bind_param", referenced from: QMYSQLResult::exec() in qsql_mysql.cpp.o "_mysql_stmt_bind_result", referenced from: QMYSQLResult::exec() in qsql_mysql.cpp.o "_mysql_stmt_close", referenced from: QMYSQLResult::cleanup() in qsql_mysql.cpp.o QMYSQLDriver::open(QString const&, QString const&, QString const&, QString const&, int, QString const&) in qsql_mysql.cpp.o "_mysql_stmt_data_seek", referenced from: QMYSQLResult::fetch(int) in qsql_mysql.cpp.o "_mysql_stmt_errno", referenced from: qMakeStmtError(QString const&, QSqlError::ErrorType, MYSQL_STMT*) in qsql_mysql.cpp.o "_mysql_stmt_error", referenced from: qMakeStmtError(QString const&, QSqlError::ErrorType, MYSQL_STMT*) in qsql_mysql.cpp.o "_mysql_stmt_execute", referenced from: QMYSQLResult::exec() in qsql_mysql.cpp.o "_mysql_stmt_fetch", referenced from: QMYSQLResult::fetch(int) in qsql_mysql.cpp.o QMYSQLResult::fetchNext() in qsql_mysql.cpp.o "_mysql_stmt_free_result", referenced from: QMYSQLResult::detachFromResultSet() in qsql_mysql.cpp.o "_mysql_stmt_init", referenced from: QMYSQLResult::prepare(QString const&) in qsql_mysql.cpp.o QMYSQLDriver::open(QString const&, QString const&, QString const&, QString const&, int, QString const&) in qsql_mysql.cpp.o "_mysql_stmt_insert_id", referenced from: QMYSQLResult::lastInsertId() const in qsql_mysql.cpp.o "_mysql_stmt_num_rows", referenced from: QMYSQLResult::fetchLast() in qsql_mysql.cpp.o QMYSQLResult::size() in qsql_mysql.cpp.o "_mysql_stmt_param_count", referenced from: QMYSQLResult::prepare(QString const&) in qsql_mysql.cpp.o QMYSQLResult::exec() in qsql_mysql.cpp.o QMYSQLDriver::open(QString const&, QString const&, QString const&, QString const&, int, QString const&) in qsql_mysql.cpp.o "_mysql_stmt_prepare", referenced from: QMYSQLResult::prepare(QString const&) in qsql_mysql.cpp.o QMYSQLDriver::open(QString const&, QString const&, QString const&, QString const&, int, QString const&) in qsql_mysql.cpp.o "_mysql_stmt_reset", referenced from: QMYSQLResult::exec() in qsql_mysql.cpp.o "_mysql_stmt_result_metadata", referenced from: QMYSQLResultPrivate::bindInValues() in qsql_mysql.cpp.o "_mysql_stmt_store_result", referenced from: QMYSQLResult::exec() in qsql_mysql.cpp.o "_mysql_store_result", referenced from: QMYSQLResult::cleanup() in qsql_mysql.cpp.o QMYSQLResult::reset(QString const&) in qsql_mysql.cpp.o QMYSQLResult::nextResult() in qsql_mysql.cpp.o "_mysql_thread_end", referenced from: QMYSQLDriver::close() in qsql_mysql.cpp.o "_mysql_thread_init", referenced from: QMYSQLDriver::open(QString const&, QString const&, QString const&, QString const&, int, QString const&) in qsql_mysql.cpp.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) [10/11] Building C object sqlite/CMakeFiles/QSQLiteDriverPlugin.dir/Users/chriam/Qt/6.3.1/Src/qtbase/src/3rdparty/sqlite/sqlite3.c.o ninja: build stopped: subcommand failed.
May I once again ask you what I could do to fix it? Thanks a lot, appreciate your help,
Christoph
ps: I also tried to modify the CMakeCache.txt in the build directory, removing x86_64 from the line
//List of architectures Qt was built with QT_OSX_ARCHITECTURES:STRING=x86_64;arm64
but not unexpected it had no effect...
-
Hi,
Does your installed MySQL libraries also provide symbols for both architectures ?
-
@SGaist Yes, since you're compiling/building from source
@chriam I missed that you're using Ninja (I deleted my previous post)
Because you're on Ninja, that explains the missing link.txt.
Instead:- do the ..acos/bin/qt-cmake... as before
- edit build.ninja file (it should be in the /Users/chriam/Qt/6.3.1/Src/qtbase/src/plugins/sqldrivers directory) so that Ninja builds for arm64.
Easiest is to use sed:
sed -i -e 's/-arch x86_64/-arch arm64/g' /Users/chriam/Qt/6.3.1/Src/qtbase/src/plugins/sqldrivers/build.ninja
- try cmake --build .
-
@hskoglund are we talking about the same thing ? I was thinking about the MySQL pre-built libraries that are likely used to link against.
-
@SGaist Sorry I thought you meant the MySQL stuff from Qt 6.3.1.
The prebuilt MySQL driver installed via Homebrew is only built for one architecture:
file /usr/local/lib/libmysqlclient.dylib /usr/local/lib/libmysqlclient.dylib: Mach-O 64-bit dynamically linked shared library arm64
This is a different approach that all binaries from Qt and Apple where both architectures are included more here
-
Dear both of you
Everything seems to be fine, GREAT!
chriam: ~/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers % /Users/chriam/Qt/6.3.1/macos/bin/qt-cmake -G Ninja /Users/chriam/Qt/6.3.1/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=/Users/chriam/Qt/6.3.1/macos -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.dylib" -DCMAKE_OSX_ARCHITECTURES="arm64" -- The CXX compiler identification is AppleClang 13.1.6.13160021 -- The C compiler identification is AppleClang 13.1.6.13160021 -- The ASM compiler identification is Clang with GNU-like command-line -- Found assembler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/clang++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/clang - skipped -- Detecting C compile features -- Detecting C compile features - done -- Looking for pthread.h -- Looking for pthread.h - found -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE -- Performing Test HAVE_STDATOMIC -- Performing Test HAVE_STDATOMIC - Success -- Found WrapAtomic: TRUE -- Configuration summary has been written to /Users/chriam/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers/config.summary -- Configure with --log-level=STATUS or higher to increase the output verbosity. -- Configuring done -- Generating done -- Build files have been written to: /Users/chriam/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers chriam: ~/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers % sed -i -e 's/-arch x86_64/-arch arm64/g' /Users/chriam/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers/build.ninja chriam: ~/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers % pwd /Users/chriam/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers chriam: ~/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers % ls CMakeCache.txt CTestTestfile.cmake build.ninja-e config.summary mysql qtsqldrivers-config.h sqlite CMakeFiles build.ninja cmake_install.cmake lib plugins qtsqldrivers-config_p.h chriam: ~/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers % cmake --build . [9/11] Linking CXX shared module plugins/sqldrivers/libqsqlmysql.dylib ld: warning: linking against a dylib which is not safe for use in application extensions: /usr/local/mysql/lib/libmysqlclient.dylib [11/11] Linking CXX shared module plugins/sqldrivers/libqsqlite.dylib chriam: ~/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers %
and the dylib is in
chriam: ~ % find ~/Qt -name libqsqlmysql.dylib /Users/chriam/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib chriam: ~ %
@hskoglund Actually, the build.ninja file is in ~/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers/build.ninja rather than in the qtbase/src subdirectory (i.e., in the build_sqldrivers directory that this time I put on a different place). I guess to install/copy it to the right place will be straight forward, I will try/do it in the next few days and let you know... I am extremely thankful for your help, appreciate a lot!
@SGaist Thanks for your input! Actually, I didn't install MySQL by Homebrew but downloaded it from Oracle (tested it, it seems to work perfectly fine). I did understand your question about the MySQL libraries regarding both architectures, but when compiling the command specifies x86_64 architecture for compiling the plugin,chriam: ~/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers % cmake --build . [8/11] Linking CXX shared module plugins/sqldrivers/libqsqlmysql.dylib FAILED: plugins/sqldrivers/libqsqlmysql.dylib : && /usr/bin/clang++ -g -DNDEBUG -O2 -arch x86_64 -isysroot ...
and the linking warning
ld: warning: ignoring file /usr/local/mysql/lib/libmysqlclient.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
suggested that the installed MySQL libraries are arm64 but the Qt plugin x86_64.
Anyhow, as I said, extremely glad that it seems to work (I will ignore the "linking against a dylib which is not safe for use in application extensions" for now), thanks again both of you,
Christoph
-
chriam: ~/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers % cmake --install . -- Install configuration: "RelWithDebInfo" -- Installing: /Users/chriam/Qt/6.3.1/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfig.cmake -- Installing: /Users/chriam/Qt/6.3.1/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfigVersion.cmake -- Installing: /Users/chriam/Qt/6.3.1/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfigVersionImpl.cmake -- Installing: /Users/chriam/Qt/6.3.1/macos/./plugins/sqldrivers/libqsqlmysql.dylib -- Installing: /Users/chriam/Qt/6.3.1/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginTargets.cmake -- Installing: /Users/chriam/Qt/6.3.1/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginTargets-relwithdebinfo.cmake -- Installing: /Users/chriam/Qt/6.3.1/macos/./plugins/sqldrivers/libqsqlmysql.dylib.dSYM -- Installing: /Users/chriam/Qt/6.3.1/macos/./plugins/sqldrivers/libqsqlmysql.dylib.dSYM/Contents -- Installing: /Users/chriam/Qt/6.3.1/macos/./plugins/sqldrivers/libqsqlmysql.dylib.dSYM/Contents/Resources -- Installing: /Users/chriam/Qt/6.3.1/macos/./plugins/sqldrivers/libqsqlmysql.dylib.dSYM/Contents/Resources/DWARF -- Installing: /Users/chriam/Qt/6.3.1/macos/./plugins/sqldrivers/libqsqlmysql.dylib.dSYM/Contents/Resources/DWARF/qsqlmysql -- Installing: /Users/chriam/Qt/6.3.1/macos/./plugins/sqldrivers/libqsqlmysql.dylib.dSYM/Contents/Info.plist -- Installing: /Users/chriam/Qt/6.3.1/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginAdditionalTargetInfo.cmake -- Installing: /Users/chriam/Qt/6.3.1/macos/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginConfig.cmake -- Installing: /Users/chriam/Qt/6.3.1/macos/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginConfigVersion.cmake -- Installing: /Users/chriam/Qt/6.3.1/macos/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginConfigVersionImpl.cmake -- Installing: /Users/chriam/Qt/6.3.1/macos/./plugins/sqldrivers/libqsqlite.dylib -- Old export file "/Users/chriam/Qt/6.3.1/macos/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginTargets.cmake" will be replaced. Removing files [/Users/chriam/Qt/6.3.1/macos/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginTargets-relwithdebinfo.cmake]. -- Installing: /Users/chriam/Qt/6.3.1/macos/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginTargets.cmake -- Installing: /Users/chriam/Qt/6.3.1/macos/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginTargets-relwithdebinfo.cmake -- Up-to-date: /Users/chriam/Qt/6.3.1/macos/./plugins/sqldrivers/libqsqlite.dylib.dSYM -- Up-to-date: /Users/chriam/Qt/6.3.1/macos/./plugins/sqldrivers/libqsqlite.dylib.dSYM/Contents -- Up-to-date: /Users/chriam/Qt/6.3.1/macos/./plugins/sqldrivers/libqsqlite.dylib.dSYM/Contents/Resources -- Up-to-date: /Users/chriam/Qt/6.3.1/macos/./plugins/sqldrivers/libqsqlite.dylib.dSYM/Contents/Resources/DWARF -- Installing: /Users/chriam/Qt/6.3.1/macos/./plugins/sqldrivers/libqsqlite.dylib.dSYM/Contents/Resources/DWARF/qsqlite -- Installing: /Users/chriam/Qt/6.3.1/macos/./plugins/sqldrivers/libqsqlite.dylib.dSYM/Contents/Info.plist -- Installing: /Users/chriam/Qt/6.3.1/macos/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginAdditionalTargetInfo.cmake chriam: ~/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers % find ~/Qt -name libqsqlmysql.dylib /Users/chriam/Qt/6.3.1/macos/plugins/sqldrivers/libqsqlmysql.dylib /Users/chriam/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib
Everything perfect!
So for anybody who struggles with the same problem: Once you know where to make the architecture spec changes (thanks again @hskoglund) the procedure to compile the Qt MySQL plugin for an M1/M2 Mac is straight forward:
chriam: ~/Qt/6.3.1/Src % ./configure -sql-mysql -- -DCMAKE_INCLUDE_PATH="/usr/local/mysql/include" -DCMAKE_LIBRARY_PATH="/usr/local/mysql/lib" … Qt Sql Drivers: DB2 (IBM) .............................. no InterBase .............................. no MySql .................................. yes OCI (Oracle) ........................... no ODBC ................................... no PostgreSQL ............................. no SQLite ................................. yes Using system provided SQLite ......... no … chriam: ~/Qt/6.3.1/macos/plugins/sqldrivers % mkdir build_sqldrivers chriam: ~/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers % /Users/chriam/Qt/6.3.1/macos/bin/qt-cmake -G Ninja /Users/chriam/Qt/6.3.1/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=/Users/chriam/Qt/6.3.1/macos -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.dylib" -DCMAKE_OSX_ARCHITECTURES="arm64" chriam: ~/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers % sed -i -e 's/-arch x86_64/-arch arm64/g' /Users/chriam/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers/build.ninja chriam: ~/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers % cmake --build . chriam: ~/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers % cmake --install . chriam: ~/Qt/6.3.1/macos/plugins/sqldrivers/build_sqldrivers % find ~/Qt -name libqsqlmysql.dylib
where the by sed the following four lines in the build.ninja file are corrected:
@SGaist: Actually, if binaries from Oracle have been downloaded, only arm64 is installed, I noticed:
-
Thanks for the detailed analysis !
-
-