Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How do I build MySQL driver for ARM-64 on MacOS?



  • So I want to rebuild a MySQL database app.
    I have installed MySQL 8.0, it has both architectures available.

    /usr/local/mysql/
    /usr/local/mysql-ARM64/

    Building the x86 plugin creates it but when I try to build the ARM64 plugin it fails. It appears to be because /usr/bin/clang++ is compiling with -arch x86_64.

    How do I switch it to ARM64?

    Configure summary:
    
    Qt Sql Drivers:
      DB2 (IBM) .............................. no
      InterBase .............................. no
      MySql .................................. yes
      OCI (Oracle) ........................... no
      ODBC ................................... no
      PostgreSQL ............................. no
      SQLite ................................. yes
        Using system provided SQLite ......... no
    
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /Users/vinceieraci/Qt/6.2.0/Src/qtbase/src/plugins/build-sqldrivers
    vinceieraci@Vinces-MBP2 build-sqldrivers % ninja
    [3/11] Building CXX object mysql/CMakeFiles/QMYSQ...QMYSQLDriverPlugin_autogen/mocs_compilation.cpp.
    In file included from mysql/QMYSQLDriverPlugin_autogen/mocs_compilation.cpp:2:
    mysql/QMYSQLDriverPlugin_autogen/EWIEGA46WW/moc_qsql_mysql_p.cpp:10:10: warning: non-portable path to file '"../../../../../../../../../../../../Users/vinceieraci/Qt/6.2.0/Src/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql_p.h"'; specified path differs in case from file name on disk [-Wnonportable-include-path]
    #include "../../../../../../../../../../../../users/vinceieraci/qt/6.2.0/Src/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql_p.h"
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             "../../../../../../../../../../../../Users/vinceieraci/Qt/6.2.0/Src/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql_p.h"
    1 warning generated.
    [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/MacOSX11.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-ARM64/lib -Wl,-rpath,/users/vinceieraci/Qt/6.2.0/macos/lib  /usr/local/mysql-ARM64/lib/libmysqlclient.dylib  /users/vinceieraci/Qt/6.2.0/macos/lib/QtSql.framework/Versions/A/QtSql  /users/vinceieraci/Qt/6.2.0/macos/lib/QtCore.framework/Versions/A/QtCore  -framework DiskArbitration  -framework IOKit && cd /Users/vinceieraci/Qt/6.2.0/Src/qtbase/src/plugins/build-sqldrivers/mysql && /opt/local/bin/cmake -E make_directory /Users/vinceieraci/Qt/6.2.0/Src/qtbase/src/plugins/build-sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib.dSYM/Contents/Resources/DWARF && /opt/local/bin/cmake -E copy Info.dSYM.plist /Users/vinceieraci/Qt/6.2.0/Src/qtbase/src/plugins/build-sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib.dSYM/Contents/Info.plist && /usr/bin/dsymutil /Users/vinceieraci/Qt/6.2.0/Src/qtbase/src/plugins/build-sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib --flat -o /Users/vinceieraci/Qt/6.2.0/Src/qtbase/src/plugins/build-sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib.dSYM/Contents/Resources/DWARF/qsqlmysql && /usr/bin/strip -S /Users/vinceieraci/Qt/6.2.0/Src/qtbase/src/plugins/build-sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib && chmod -x /Users/vinceieraci/Qt/6.2.0/Src/qtbase/src/plugins/build-sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib.dSYM/Contents/Resources/DWARF/qsqlmysql
    ld: warning: ignoring file /usr/local/mysql-ARM64/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/vinceieraci/qt/6.2.0/Src/qtbase/src/3rdparty/sqlite/sqlite3.c.o
    ninja: build stopped: subcommand failed.
    vinceieraci@Vinces-MBP2 build-sqldrivers % 
    

  • Lifetime Qt Champion

    Hi,

    Are you trying to build the whole of Qt from arm64 ?



  • @SGaist said in How do I build MySQL driver for ARM-64 on MacOS?:

    Hi,

    Are you trying to build the whole of Qt from arm64 ?

    Hi,
    No, just the MySQL plugin driver, libqsqlmysql.dylib


  • Lifetime Qt Champion

    Unless I have missed it, the pre-built binaries are currently Intel only so you won't able to build the plugin for arm64.



  • @SGaist I don't see any pre-built binaries in Qt src directory?

    CMakeList.txt
    main.cpp
    mysql.json
    sql_mysql.cpp
    

  • Lifetime Qt Champion

    Because there's no reason to have anything pre-built in the sources. I was thinking about the binaries installed using the online installer.


Log in to reply