Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MYSQL plugin on M1 Mac?
QtWS25 Last Chance

MYSQL plugin on M1 Mac?

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 3 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • chriamC Offline
    chriamC Offline
    chriam
    wrote on last edited by
    #1

    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:

    f1fd875b-aa2a-4d8c-a896-f1985b9e3c2f-Screenshot 2022-05-02 at 16.14.27.png

    Configuration is fine, but then the build fails as it compiles for x86_64 instead of macOS-arm64:

    ff9c6866-7780-45a0-a11f-b756b51e166c-Screenshot 2022-05-02 at 16.17.56.png

    I would very much appreciate any idea / hint / solution for the problem, thanks...

    --
    Christoph A. Amstutz, MD-PhD
    Department of Ophthalmology, LUKS
    Spitalstrasse, 6000 Luzern 16, Switzerland

    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #2

      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"

      1 Reply Last reply
      2
      • chriamC Offline
        chriamC Offline
        chriam
        wrote on last edited by
        #3

        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...

        --
        Christoph A. Amstutz, MD-PhD
        Department of Ophthalmology, LUKS
        Spitalstrasse, 6000 Luzern 16, Switzerland

        1 Reply Last reply
        0
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi,

            Does your installed MySQL libraries also provide symbols for both architectures ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • hskoglundH Offline
              hskoglundH Offline
              hskoglund
              wrote on last edited by
              #6

              @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:

              1. do the ..acos/bin/qt-cmake... as before
              2. 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
              1. try cmake --build .
              SGaistS 1 Reply Last reply
              0
              • hskoglundH hskoglund

                @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:

                1. do the ..acos/bin/qt-cmake... as before
                2. 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
                1. try cmake --build .
                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @hskoglund are we talking about the same thing ? I was thinking about the MySQL pre-built libraries that are likely used to link against.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                hskoglundH 1 Reply Last reply
                0
                • SGaistS SGaist

                  @hskoglund are we talking about the same thing ? I was thinking about the MySQL pre-built libraries that are likely used to link against.

                  hskoglundH Offline
                  hskoglundH Offline
                  hskoglund
                  wrote on last edited by
                  #8

                  @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

                  1 Reply Last reply
                  0
                  • chriamC Offline
                    chriamC Offline
                    chriam
                    wrote on last edited by
                    #9

                    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

                    --
                    Christoph A. Amstutz, MD-PhD
                    Department of Ophthalmology, LUKS
                    Spitalstrasse, 6000 Luzern 16, Switzerland

                    1 Reply Last reply
                    0
                    • chriamC Offline
                      chriamC Offline
                      chriam
                      wrote on last edited by
                      #10
                      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
                      

                      Screenshot 2022-08-05 at 22.49.12.png

                      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:
                      build.ninja_diff.png

                      @SGaist: Actually, if binaries from Oracle have been downloaded, only arm64 is installed, I noticed:
                      Screenshot 2022-08-07 at 10.08.51.png

                      --
                      Christoph A. Amstutz, MD-PhD
                      Department of Ophthalmology, LUKS
                      Spitalstrasse, 6000 Luzern 16, Switzerland

                      1 Reply Last reply
                      2
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        Thanks for the detailed analysis !

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        2
                        • B BushyAxis793 referenced this topic on
                        • hskoglundH hskoglund referenced this topic on

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved