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 drivers built but qt can not find them
Forum Updated to NodeBB v4.3 + New Features

Mysql drivers built but qt can not find them

Scheduled Pinned Locked Moved Unsolved General and Desktop
22 Posts 4 Posters 3.3k Views 1 Watching
  • 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.
  • Christian EhrlicherC Christian Ehrlicher

    @DeadSo0ul said in Mysql drivers built but qt can not find them:

    qt.core.plugin.factoryloader: "Failed to extract plugin meta data from '/Users/boyankiovtorov/Qt/6.7.0/macos/plugins/sqldrivers/libqsqlmysql.dylib': '/Users/boyankiovtorov/Qt/6.7.0/macos/plugins/sqldrivers/libqsqlmysql.dylib' is not a valid Mach-O binary (wrong architecture)"

    Isn't this obvious enough?

    D Offline
    D Offline
    DeadSo0ul
    wrote on last edited by DeadSo0ul
    #5

    @Christian-Ehrlicher It is, but the problem is that when I firstly tried to build for my architecture I got the error

    ld: warning: ignoring file '/usr/local/mysql-8.3.0-macos14-arm64/lib/libmysqlclient.23.dylib': found architecture 'arm64', required architecture 'x86_64'
    

    and from there my build crashed for arm64

    Here is the command I used if it helps somehow

    ./qt-cmake /Users/boyankiovtorov/Qt/6.7.0/Src/qtbase/src/plugins/sqldrivers -GNinja -DMySQL_INCLUDE_DIR=/usr/local/mysql-8.3.0-macos14-arm64/include -DMySQL_LIBRARY=/usr/local/mysql-8.3.0-macos14-arm64/lib/libmysqlclient.dylib
    
    SGaistS 1 Reply Last reply
    0
    • D DeadSo0ul

      @Christian-Ehrlicher It is, but the problem is that when I firstly tried to build for my architecture I got the error

      ld: warning: ignoring file '/usr/local/mysql-8.3.0-macos14-arm64/lib/libmysqlclient.23.dylib': found architecture 'arm64', required architecture 'x86_64'
      

      and from there my build crashed for arm64

      Here is the command I used if it helps somehow

      ./qt-cmake /Users/boyankiovtorov/Qt/6.7.0/Src/qtbase/src/plugins/sqldrivers -GNinja -DMySQL_INCLUDE_DIR=/usr/local/mysql-8.3.0-macos14-arm64/include -DMySQL_LIBRARY=/usr/local/mysql-8.3.0-macos14-arm64/lib/libmysqlclient.dylib
      
      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #6

      @DeadSo0ul hi,

      Do you have an Intel or an M series machine ?

      You need to either have MySQL for x86_64 or build Qt for arm64.

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

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

        Hi @SGaist don't worry about Qt's architectures, I think at least from 6.2 the online version installs both of them, e.g.

        file ~/Qt/6.7.0/macos/lib/QtCore.framework/QtCore
        /Users/henry/Qt/6.7.0/macos/lib/QtCore.framework/QtCore: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [arm64]
        /Users/henry/Qt/6.7.0/macos/lib/QtCore.framework/QtCore (for architecture x86_64):	Mach-O 64-bit dynamically linked shared library x86_64
        /Users/henry/Qt/6.7.0/macos/lib/QtCore.framework/QtCore (for architecture arm64):	Mach-O 64-bit dynamically linked shared library arm64
        

        However homebrew (where you usually get the MySql stuff) only gives you one architecture, so you have to check with file

        D SGaistS 2 Replies Last reply
        0
        • SGaistS SGaist

          @DeadSo0ul hi,

          Do you have an Intel or an M series machine ?

          You need to either have MySQL for x86_64 or build Qt for arm64.

          D Offline
          D Offline
          DeadSo0ul
          wrote on last edited by
          #8

          @SGaist Hi
          I am on a M series machine. Does that build have to be done manually or is it done during installation of Qt. I can not have MySQL for x86-x64 as it won't link the driver

          1 Reply Last reply
          0
          • hskoglundH hskoglund

            Hi @SGaist don't worry about Qt's architectures, I think at least from 6.2 the online version installs both of them, e.g.

            file ~/Qt/6.7.0/macos/lib/QtCore.framework/QtCore
            /Users/henry/Qt/6.7.0/macos/lib/QtCore.framework/QtCore: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [arm64]
            /Users/henry/Qt/6.7.0/macos/lib/QtCore.framework/QtCore (for architecture x86_64):	Mach-O 64-bit dynamically linked shared library x86_64
            /Users/henry/Qt/6.7.0/macos/lib/QtCore.framework/QtCore (for architecture arm64):	Mach-O 64-bit dynamically linked shared library arm64
            

            However homebrew (where you usually get the MySql stuff) only gives you one architecture, so you have to check with file

            D Offline
            D Offline
            DeadSo0ul
            wrote on last edited by
            #9

            @hskoglund Hi,
            I installed mysql from its official site.
            I checked the architecture

            /Users/boyankiovtorov/Qt/6.7.0/macos/lib/QtCore.framework/QtCore: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [arm64]
            /Users/boyankiovtorov/Qt/6.7.0/macos/lib/QtCore.framework/QtCore (for architecture x86_64):	Mach-O 64-bit dynamically linked shared library x86_64
            /Users/boyankiovtorov/Qt/6.7.0/macos/lib/QtCore.framework/QtCore (for architecture arm64):	Mach-O 64-bit dynamically linked shared library arm64
            

            Should I install through homebrew?

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

              Hi, just try your qt-cmake command again, but this put this at the end:

              -DCMAKE_OSX_ARCHITECTURES="arm64"
              
              D 1 Reply Last reply
              0
              • hskoglundH hskoglund

                Hi @SGaist don't worry about Qt's architectures, I think at least from 6.2 the online version installs both of them, e.g.

                file ~/Qt/6.7.0/macos/lib/QtCore.framework/QtCore
                /Users/henry/Qt/6.7.0/macos/lib/QtCore.framework/QtCore: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [arm64]
                /Users/henry/Qt/6.7.0/macos/lib/QtCore.framework/QtCore (for architecture x86_64):	Mach-O 64-bit dynamically linked shared library x86_64
                /Users/henry/Qt/6.7.0/macos/lib/QtCore.framework/QtCore (for architecture arm64):	Mach-O 64-bit dynamically linked shared library arm64
                

                However homebrew (where you usually get the MySql stuff) only gives you one architecture, so you have to check with file

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #11

                @hskoglund if it's a custom build, I want to worry about it :-)

                @DeadSo0ul the long variant would be to get a multi-arch MySQL or get it for each architecture and use lipo to put them together.

                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 hskoglund

                  Hi, just try your qt-cmake command again, but this put this at the end:

                  -DCMAKE_OSX_ARCHITECTURES="arm64"
                  
                  D Offline
                  D Offline
                  DeadSo0ul
                  wrote on last edited by
                  #12

                  @hskoglund
                  I still get the same result

                  ld: warning: ignoring file '/usr/local/mysql-8.3.0-macos14-arm64/lib/libmysqlclient.23.dylib': found architecture 'arm64', required architecture 'x86_64'
                  
                  1 Reply Last reply
                  0
                  • hskoglundH Offline
                    hskoglundH Offline
                    hskoglund
                    wrote on last edited by hskoglund
                    #13

                    You need to nuke (delete) the previous build/directory
                    or do a new download and then try qt-cmake again (with -DCMAKE_OSX_ARCHITECTURES="arm64" added at the end)

                    D 1 Reply Last reply
                    0
                    • hskoglundH hskoglund

                      You need to nuke (delete) the previous build/directory
                      or do a new download and then try qt-cmake again (with -DCMAKE_OSX_ARCHITECTURES="arm64" added at the end)

                      D Offline
                      D Offline
                      DeadSo0ul
                      wrote on last edited by DeadSo0ul
                      #14

                      @hskoglund If I do understand you correctly I had done it before running the command as the files built were easy to trackScreenshot 2024-04-16 at 22.57.57.png

                      Ignore the directory where I build as I overkill the whole process for no reason

                      I did try to build in another directory but without success

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

                        No I mean delete all of the /Users/boyankiovtorov/Qt/6.7.0/Src/qtbase/src/plugins/sqldrivers directory
                        If you don't have a copy easiest is just to download the 6.7.0 source again.

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

                          Here's how I built MySQL (some time ago :-) using Homebrew
                          Download Qt sources in ~/Downloads then do these commands:

                          brew install mysql
                          cd ~/Downloads/qt-everywhere-src-6.7.0/qtbase/src/plugins/sqldrivers
                          ~/Qt/6.7.0/macos/bin/qt-cmake -DMySQL_LIBRARY=/usr/local/opt/mysql/lib/libmysqlclient.dylib -DMySQL_INCLUDE_DIR=/usr/local/opt/mysql/include/mysql  -DCMAKE_OSX_ARCHITECTURES="arm64" .
                          make
                          
                          D 1 Reply Last reply
                          0
                          • hskoglundH hskoglund

                            Here's how I built MySQL (some time ago :-) using Homebrew
                            Download Qt sources in ~/Downloads then do these commands:

                            brew install mysql
                            cd ~/Downloads/qt-everywhere-src-6.7.0/qtbase/src/plugins/sqldrivers
                            ~/Qt/6.7.0/macos/bin/qt-cmake -DMySQL_LIBRARY=/usr/local/opt/mysql/lib/libmysqlclient.dylib -DMySQL_INCLUDE_DIR=/usr/local/opt/mysql/include/mysql  -DCMAKE_OSX_ARCHITECTURES="arm64" .
                            make
                            
                            D Offline
                            D Offline
                            DeadSo0ul
                            wrote on last edited by
                            #17

                            @hskoglund
                            It was the same way I built the driver for 6.2 but still not working

                            cd ~/Downloads/qt-everywhere-src-6.7.0/qtbase/src/plugins/sqldrivers
                            boyankiovtorov@Boyans-MacBook-Air sqldrivers % ~/Qt/6.7.0/macos/bin/qt-cmake -DMySQL_LIBRARY=/opt/homebrew/opt/mysql/lib/libmysqlclient.dylib -DMySQL_INCLUDE_DIR=/opt/homebrew/opt/mysql/include/mysql  -DCMAKE_OSX_ARCHITECTURES="arm64" .
                            

                            it gives a warning that ninja is recommended

                            CMake Warning at /Users/boyankiovtorov/Qt/6.7.0/macos/lib/cmake/Qt6/QtBuildHelpers.cmake:12 (message):
                              The officially supported CMake generator for building Qt is Ninja / Ninja
                              Multi-Config.  You are using: 'Unix Makefiles' instead.  Thus, you might
                              encounter issues.  Use at your own risk.
                            Call Stack (most recent call first):
                              /Users/boyankiovtorov/Qt/6.7.0/macos/lib/cmake/Qt6/QtBuildHelpers.cmake:381 (qt_internal_validate_cmake_generator)
                              /Users/boyankiovtorov/Qt/6.7.0/macos/lib/cmake/Qt6/QtBuild.cmake:4 (qt_internal_setup_build_and_global_variables)
                              /Users/boyankiovtorov/Qt/6.7.0/macos/lib/cmake/Qt6/QtSetup.cmake:6 (include)
                              /Users/boyankiovtorov/Qt/6.7.0/macos/lib/cmake/Qt6/QtBuildRepoHelpers.cmake:21 (include)
                              /Users/boyankiovtorov/Qt/6.7.0/macos/lib/cmake/Qt6/QtBuildRepoHelpers.cmake:112 (qt_build_internals_set_up_private_api)
                              CMakeLists.txt:26 (qt_prepare_standalone_project)
                            

                            but the error is still the same

                            [ 41%] Linking CXX shared module ../plugins/sqldrivers/libqsqlmysql.dylib
                            ld: warning: ignoring file '/opt/homebrew/Cellar/mysql/8.3.0_1/lib/libmysqlclient.23.dylib': found architecture 'arm64', required architecture 'x86_64'
                            
                            1 Reply Last reply
                            0
                            • hskoglundH Offline
                              hskoglundH Offline
                              hskoglund
                              wrote on last edited by
                              #18

                              If you check the MySql dll with file, e.g.:

                              file /opt/homebrew/opt/mysql/lib/libmysqlclient.dylib 
                              

                              If it says "x86_64" then you need to download/install a dylib/dll with the same name but has the architecture "arm64"

                              D 1 Reply Last reply
                              0
                              • hskoglundH hskoglund

                                If you check the MySql dll with file, e.g.:

                                file /opt/homebrew/opt/mysql/lib/libmysqlclient.dylib 
                                

                                If it says "x86_64" then you need to download/install a dylib/dll with the same name but has the architecture "arm64"

                                D Offline
                                D Offline
                                DeadSo0ul
                                wrote on last edited by
                                #19

                                @hskoglund It is arm64

                                /opt/homebrew/opt/mysql/lib/libmysqlclient.dylib: Mach-O 64-bit dynamically linked shared library arm64
                                
                                1 Reply Last reply
                                0
                                • hskoglundH Offline
                                  hskoglundH Offline
                                  hskoglund
                                  wrote on last edited by
                                  #20

                                  Hi, indeed I just tried it myself and something's changed with 6.7.0, that switch -DCMAKE_OSX_ARCHITECTURES="arm64" does not seem to work anymore :-(
                                  I remember that was a bug before and that you had to edit some cmake text file, i'll check...

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

                                    Hi, found it: https://forum.qt.io/topic/136231/mysql-plugin-on-m1-mac/10

                                    Adding -DCMAKE_OSX_ARCHITECTURES="arm64" has not been sufficient for a looong time.

                                    The good news is that for Qt 6.7.0 it's slightly easier. Anyway there are two things that has be fixed: build with Nnja and manually edit the Ninja build file before issuing the cmake --build .

                                    So the qt-cmake command should be:
                                    ~/Qt/6.7.0/macos/bin/qt-cmake -GNinja -DMySQL_LIBRARY=/opt/homebrew/opt/mysql/lib/libmysqlclient.dylib -DMySQL_INCLUDE_DIR=/opt/homebrew/opt/mysql/include/mysql -DCMAKE_OSX_ARCHITECTURES="arm64" .

                                    Once it's done, do this magic command:

                                    sed -i -e 's/-arch x86_64/-arch arm64/g' build.ninja
                                    

                                    Then proceed with the usual:

                                    cmake --build .
                                    

                                    Don't forget to nuke the sqldrivers directory first :-)

                                    D 1 Reply Last reply
                                    3
                                    • hskoglundH hskoglund

                                      Hi, found it: https://forum.qt.io/topic/136231/mysql-plugin-on-m1-mac/10

                                      Adding -DCMAKE_OSX_ARCHITECTURES="arm64" has not been sufficient for a looong time.

                                      The good news is that for Qt 6.7.0 it's slightly easier. Anyway there are two things that has be fixed: build with Nnja and manually edit the Ninja build file before issuing the cmake --build .

                                      So the qt-cmake command should be:
                                      ~/Qt/6.7.0/macos/bin/qt-cmake -GNinja -DMySQL_LIBRARY=/opt/homebrew/opt/mysql/lib/libmysqlclient.dylib -DMySQL_INCLUDE_DIR=/opt/homebrew/opt/mysql/include/mysql -DCMAKE_OSX_ARCHITECTURES="arm64" .

                                      Once it's done, do this magic command:

                                      sed -i -e 's/-arch x86_64/-arch arm64/g' build.ninja
                                      

                                      Then proceed with the usual:

                                      cmake --build .
                                      

                                      Don't forget to nuke the sqldrivers directory first :-)

                                      D Offline
                                      D Offline
                                      DeadSo0ul
                                      wrote on last edited by
                                      #22

                                      @hskoglund
                                      That worked! Thank you so much.

                                      1 Reply Last reply
                                      0
                                      • hskoglundH hskoglund referenced this topic on
                                      • H he_R0 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