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. building Qt MYSQL driver for MAC OS Monterey
Forum Updated to NodeBB v4.3 + New Features

building Qt MYSQL driver for MAC OS Monterey

Scheduled Pinned Locked Moved Unsolved General and Desktop
32 Posts 7 Posters 4.4k Views 3 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.
  • A Offline
    A Offline
    Achab61
    wrote on 13 Mar 2022, 09:23 last edited by
    #1

    I'm trying to build Qt MySQL driver on MAC OS Monterey from the Terminal shell as follows:

    cd /Users/MyUser/qt/6.2.3/macos/plugins/sqldrivers
    Qmake -- MYSQL_PREFIX=/usr/local/mysql-8.0.28-macos11-x86_64 (the location where MySQL is installed)

    but QMake is presenting the Help Menu rather than executing

    Usage: Qmake [mode] [options] [files]

    QMake has two modes, one mode for generating project files based on some heuristics, and the other for generating makefiles. Normally you shouldn't need to specify a mode, as makefile generation is the default mode for qmake, but you may use this to test qmake on an existing project

    Thanks for any help

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 13 Mar 2022, 09:39 last edited by Christian Ehrlicher
      #2

      @Achab61 said in building Qt MYSQL driver for MAC OS Monterey:

      cd /Users/MyUser/qt/6.2.3/macos/plugins/sqldrivers
      Qmake

      This is wrong, please follow the documentation.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Achab61
        wrote on 13 Mar 2022, 10:50 last edited by
        #3

        Reading the documentation, at least for me, is not so helpful. Looking at the section "How to Build the QMYSQL Plugin on Unix and macOS" of the documentation it's reported the following command:

        qt-cmake -G Ninja <qt_installation_path>/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.<so|dylib>"

        But in my Qt installation there's no Src subfolder. Below is how my Qt path looks like.

        So, I'm a bit confused.

        Screenshot 2022-03-13 at 11.36.52.png

        M 1 Reply Last reply 13 Mar 2022, 10:58
        0
        • A Achab61
          13 Mar 2022, 10:50

          Reading the documentation, at least for me, is not so helpful. Looking at the section "How to Build the QMYSQL Plugin on Unix and macOS" of the documentation it's reported the following command:

          qt-cmake -G Ninja <qt_installation_path>/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.<so|dylib>"

          But in my Qt installation there's no Src subfolder. Below is how my Qt path looks like.

          So, I'm a bit confused.

          Screenshot 2022-03-13 at 11.36.52.png

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 13 Mar 2022, 10:58 last edited by mrjj
          #4

          @Achab61
          Hi
          Run the qt maintenance tool and checkmark the source so it's installed also.

          alt text

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Achab61
            wrote on 13 Mar 2022, 11:43 last edited by
            #5

            @mrjj - Thanks for your hint. I did what you suggested and I got the src folder.
            However, running the command below now I'm getting the following error:

            /users/MyUser/Qt/6.2.3/macos/bin/qt-cmake: line 17: exec: cmake: not found

            Any clue about the reason ? Thanks

            qt-cmake -G Ninja /Users/MyUser/Qt/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=/Users/MyUser/Qt/6.2.3 -DMySQL_INCLUDE_DIR="/usr/local/mysql-8.0.28-macos11-x86_64/include" -DMySQL_LIBRARY="/usr/local/mysql-8.0.28-macos11-x86_64/lib/libmysqlclient.<so|dylib>

            M 1 Reply Last reply 13 Mar 2022, 11:54
            0
            • A Achab61
              13 Mar 2022, 11:43

              @mrjj - Thanks for your hint. I did what you suggested and I got the src folder.
              However, running the command below now I'm getting the following error:

              /users/MyUser/Qt/6.2.3/macos/bin/qt-cmake: line 17: exec: cmake: not found

              Any clue about the reason ? Thanks

              qt-cmake -G Ninja /Users/MyUser/Qt/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=/Users/MyUser/Qt/6.2.3 -DMySQL_INCLUDE_DIR="/usr/local/mysql-8.0.28-macos11-x86_64/include" -DMySQL_LIBRARY="/usr/local/mysql-8.0.28-macos11-x86_64/lib/libmysqlclient.<so|dylib>

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 13 Mar 2022, 11:54 last edited by mrjj
              #6

              @Achab61
              Do you have cmake.exe in your path?
              On windows its "C:\Qt\6.2.0\msvc2019_64\bin\qt-cmake.bat"
              and that calls cmake.exe in the script so I assume its same on MAC and
              the error is that the script file cant locate the real cmake.exe.
              On Windows its a separate install. Not included with Qt.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                Achab61
                wrote on 13 Mar 2022, 13:30 last edited by
                #7

                @mrjj On Mac I have qt-cmake and qmake executables under /Users/MyUser/Qt/6.2.3/macos/bin while there is CMake.app application under /Users/MyUser/Qt/Tools but I can't find cmake executable

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  Achab61
                  wrote on 13 Mar 2022, 16:20 last edited by
                  #8

                  Update: I was able to install cmake using 'brew install cmake' but now when I run the command :

                  qt-cmake -G Ninja /Users/MyUser/Qt/6.2.3/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=/Users/MyUser/Qt/6.2.3 -DMySQL_INCLUDE_DIR="/usr/local/mysql-8.0.28-macos11-x86_64/include" -DMySQL_LIBRARY="/usr/local/mysql-8.0.28-macos11-x86_64/lib/libmysqlclient.<so|dylib>"

                  I get the error:

                  CMake Error: The source "/users/MyUser/Qt/6.2.3/Src/qtbase/src/plugins/sqldrivers/CMakeLists.txt" does not match the source "/Users/MyUser/Qt/6.2.3/Src/qtbase/src/plugins/sqldrivers/mysql/CMakeLists.txt" used to generate cache. Re-run cmake with a different source directory.

                  I checked the two mentioned CMakeLists.txt which are actually different but I don't know the exact meaning of that.

                  Suggestions are welcome. Thanks

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 13 Mar 2022, 20:05 last edited by
                    #9

                    Hi,

                    Delete the build folder where you tried first and start from scratch.

                    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
                    1
                    • A Offline
                      A Offline
                      Achab61
                      wrote on 14 Mar 2022, 09:30 last edited by
                      #10

                      OK, I'll do that.

                      I have one doubt about the command reported in the documentation:

                      qt-cmake -G Ninja <qt_installation_path>/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.<so|dylib>"

                      specifically: in -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> , what should I put as <platform> ?

                      Thanks for any hint

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mchinand
                        wrote on 14 Mar 2022, 12:59 last edited by
                        #11

                        @Achab61 said in building Qt MYSQL driver for MAC OS Monterey:

                        -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> , what should I put as <platform>

                        The sub-directory of your Qt installation after the Qt version, e.g., on Windows for Visual Studio, it is typically -DCMAKE_INSTALL_PREFIX=C:/Qt/6.2.3/msvc2019_64. This will have the bin and lib (and others) sub-directories related to that Qt version and platform combination.

                        1 Reply Last reply
                        1
                        • A Offline
                          A Offline
                          Achab61
                          wrote on 14 Mar 2022, 13:33 last edited by
                          #12

                          Thanks @mchinand.

                          I launched the command and, as far as I understood, it seems it did something.
                          However, I get a warning and the error I marked below in bold.

                          Additionally if I try to run 'cmake --build' as reported in the documentation (https://doc.qt.io/qt-6/sql-driver.html#building-the-drivers) I get the cmake --build help menu.

                          If anyone may help, it would be great. Thanks

                          -- The CXX compiler identification is AppleClang 13.0.0.13000029
                          -- The C compiler identification is AppleClang 13.0.0.13000029
                          -- The ASM compiler identification is Clang with GNU-like command-line
                          -- Found assembler: /Library/Developer/CommandLineTools/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
                          -- Check for feature set changes
                          -- Looking for a OBJC compiler
                          -- Looking for a OBJC compiler - /Library/Developer/CommandLineTools/usr/bin/clang
                          -- The OBJC compiler identification is AppleClang 13.0.0.13000029
                          -- Detecting OBJC compiler ABI info
                          -- Detecting OBJC compiler ABI info - done
                          -- Check for working OBJC compiler: /Library/Developer/CommandLineTools/usr/bin/clang - skipped
                          -- Looking for a OBJCXX compiler
                          -- Looking for a OBJCXX compiler - /Library/Developer/CommandLineTools/usr/bin/clang++
                          -- The OBJCXX compiler identification is AppleClang 13.0.0.13000029
                          -- Detecting OBJCXX compiler ABI info
                          -- Detecting OBJCXX compiler ABI info - done
                          -- Check for working OBJCXX compiler: /Library/Developer/CommandLineTools/usr/bin/clang++ - skipped
                          -- Could NOT find DB2 (missing: DB2_INCLUDE_DIR DB2_LIBRARY)
                          -- Found MySQL: /usr/local/mysql-8.0.28-macos11-x86_64/lib/libmysqlclient.dylib”

                          -- Could NOT find PostgreSQL (missing: PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR)
                          -- Could NOT find Oracle (missing: Oracle_LIBRARY Oracle_INCLUDE_DIR)
                          -- Found ODBC: /Library/Frameworks/iodbc.framework
                          -- Found SQLite3: /Library/Frameworks/Mono.framework/Headers (found version "3.26.0")
                          -- Could NOT find Interbase (missing: Interbase_LIBRARY Interbase_INCLUDE_DIR)
                          -- Performing Test HAVE_DASH_UNDEFINED_SYMBOLS
                          -- Performing Test HAVE_DASH_UNDEFINED_SYMBOLS - Success
                          -- Performing Test HAVE_DASH_DASH_NO_UNDEFINED
                          -- Performing Test HAVE_DASH_DASH_NO_UNDEFINED - Failed
                          -- The following packages have been found:

                          • Qt6BuildInternals (required version >= 6.2.3)
                          • Qt6CoreTools (required version >= 6.2.3)
                          • Qt6Core (required version >= 6.2.3)
                          • Qt6Sql (required version >= 6.2.3)
                          • Qt6 (required version >= 6.2.3)
                          • MySQL, MySQL client library, https://www.mysql.com
                          • SQLite3
                          • ODBC

                          -- The following OPTIONAL packages have not been found:

                          • DB2, IBM DB2 client library, https://www.ibm.com
                          • PkgConfig
                          • PostgreSQL
                          • Oracle, Oracle client library, https://www.oracle.com
                          • Interbase, Interbase client library, https://www.embarcadero.com/products/interbase

                          Configure summary:

                          Qt Sql Drivers:
                          DB2 (IBM) .............................. no
                          InterBase .............................. no
                          MySql .................................. yes
                          OCI (Oracle) ........................... no
                          ODBC ................................... yes
                          PostgreSQL ............................. no
                          SQLite ................................. yes
                          Using system provided SQLite ......... no

                          -- Configuring done
                          ![CMake Warning:
                          Value of MySQL_LIBRARY contained a newline; truncating]

                          -- Generating done
                          **CMake Error:
                          Running

                          '/Users/MyUser/Qt/Tools/Ninja/ninja' '-C' '/Users/MyUser/build_mysql_driver' '-t' 'recompact'

                          failed with:

                          ninja: error: build.ninja:179: expected variable name
                          /users/MyUser/Qt/6.2.3/macos/lib/QtSql.framework/Versions/A/QtSql /use...
                          ^ near here
                          **

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on 14 Mar 2022, 21:10 last edited by
                            #13

                            Looks like the content of MySQL_LIBRARY contains something wrong. Can you share the exact command you used ?

                            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
                            1
                            • A Offline
                              A Offline
                              Achab61
                              wrote on 15 Mar 2022, 09:58 last edited by
                              #14

                              This is the command I type:

                              qt-cmake -G Ninja /Users/MyUser/Qt/6.2.3/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=/Users/MyUser/Qt/6.2.3/macos -DMySQL_INCLUDE_DIR="/usr/local/mysql-8.0.28-macos11-x86_64/include" -DMySQL_LIBRARY="/usr/local/mysql-8.0.28-macos11-x86_64/lib/libmysqlclient.dylib>”

                              1 Reply Last reply
                              0
                              • hskoglundH Offline
                                hskoglundH Offline
                                hskoglund
                                wrote on 15 Mar 2022, 11:10 last edited by
                                #15

                                Hi, try removing the > at the very end, i.e. after ...libmysqlclient.dylib

                                1 Reply Last reply
                                2
                                • A Offline
                                  A Offline
                                  Achab61
                                  wrote on 15 Mar 2022, 15:36 last edited by
                                  #16

                                  I did it, but I get the same message:

                                  CMake Warning:
                                  Value of MySQL_LIBRARY contained a newline; truncating

                                  -- Generating done
                                  CMake Error:
                                  Running

                                  '/Users/MyUser/Qt/Tools/Ninja/ninja' '-C' '/Users/MyUser/build_mysql_driver' '-t' 'recompact'

                                  failed with:

                                  ninja: error: build.ninja:179: expected variable name
                                  /users/MyUser/Qt/6.2.3/macos/lib/QtSql.framework/Versions/A/QtSql /use...
                                  ^ near here

                                  1 Reply Last reply
                                  0
                                  • hskoglundH Offline
                                    hskoglundH Offline
                                    hskoglund
                                    wrote on 15 Mar 2022, 19:20 last edited by
                                    #17

                                    Hi, it could be because cmake remembers the old command in its cache.
                                    Try (as @SGaist says above) delete the whole sqldrivers directory in Users/MyUser/Qt/6.2.3/Src/qtbase/src/plugins and install the sources again.

                                    1 Reply Last reply
                                    1
                                    • A Offline
                                      A Offline
                                      Achab61
                                      wrote on 16 Mar 2022, 13:01 last edited by
                                      #18

                                      @hskoglund, @SGaist : you were right. Thanks!

                                      Reinstalling the Qt sources the "Qt -cmake" command ended correctly without neither warnings nor errors (see below).

                                      -- Configuring done
                                      -- Generating done
                                      -- Build files have been written to: /Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers

                                      Now I'm facing (maybe..) another issue: in the documentation it's reported run the following commands:

                                      cmake --build
                                      cmake --install

                                      But when I type cmake --build I get the cmake --build help menu and I don't know why.
                                      Thanks for any hint

                                      Here below the screenshot of the /sqldrivers and /sqldrivers/mysql folders

                                      Screenshot 2022-03-16 at 13.49.09.png

                                      Screenshot 2022-03-16 at 13.49.58.png

                                      1 Reply Last reply
                                      0
                                      • SGaistS Offline
                                        SGaistS Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        wrote on 16 Mar 2022, 13:31 last edited by
                                        #19

                                        You forgot the dot after the command.

                                        cmake --build .
                                        cmake --install .
                                        

                                        It's not punctuation in this case ;-)

                                        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
                                        1
                                        • M Offline
                                          M Offline
                                          mchinand
                                          wrote on 16 Mar 2022, 13:31 last edited by mchinand
                                          #20

                                          You need to specify the directory (adding a dot as in the documentation to specify the current directory). https://doc-snapshots.qt.io/qt6-dev/sql-driver.html#how-to-build-the-qmysql-plugin-on-unix-and-macos

                                          cmake --build .
                                          cmake --install .
                                          

                                          The display of the help does have useful information to help you out:

                                          Usage: cmake --build <dir>             [options] [-- [native-options]]
                                                 cmake --build --preset <preset> [options] [-- [native-options]]
                                          Options:
                                            <dir>          = Project binary directory to be built.
                                          
                                          1 Reply Last reply
                                          1

                                          1/32

                                          13 Mar 2022, 09:23

                                          • Login

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