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.5k 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.
  • hskoglundH Offline
    hskoglundH Offline
    hskoglund
    wrote on 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 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 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 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 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 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
              • A Offline
                A Offline
                Achab61
                wrote on last edited by
                #21

                Launching cmake --build . it ends up with errors (below the output).
                For what I see, there are 2 fatal errors : /Library/Frameworks/iODBC.framework/Headers/sql.h:89:10: 'iODBC/sqltypes.h' file not found
                However, if I look into /Library/Frameworks/iODBC.framework/Headers/ I see both sql.h and sqltypes.h existing in such directory.

                Thanks once more for any support

                /Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers % cmake --build .

                [6/16] Building CXX object odbc/CMakeFiles/QODBCDriverPlugin.dir/qsql_odbc.cpp.o
                FAILED: odbc/CMakeFiles/QODBCDriverPlugin.dir/qsql_odbc.cpp.o
                /usr/bin/clang++ -DGL_SILENCE_DEPRECATION -DQODBCDriverPlugin_EXPORTS -DQT_CORE_LIB -DQT_DEPRECATED_WARNINGS -DQT_DEPRECATED_WARNINGS_SINCE=0x060000 -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_DEBUG -DQT_NO_EXCEPTIONS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_PLUGIN -DQT_SQL_LIB -DUNICODE -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I/Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers/odbc/QODBCDriverPlugin_autogen/include -I/Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers/odbc -I/Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers/include -isystem /Library/Frameworks/iODBC.framework/Headers -iframework /Users/MyUser/Qt/6.2.3/macos/lib -isystem /Users/MyUser/Qt/6.2.3/macos/lib/QtCore.framework/Headers -isystem /Users/MyUser/Qt/6.2.3/macos/mkspecs/macx-clang -isystem /Users/MyUser/Qt/6.2.3/macos/include -isystem /Users/MyUser/Qt/6.2.3/macos/lib/QtCore.framework/Headers/6.2.3 -isystem /Users/MyUser/Qt/6.2.3/macos/lib/QtCore.framework/Headers/6.2.3/QtCore -isystem /Users/MyUser/Qt/6.2.3/macos/lib/QtSql.framework/Headers/6.2.3 -isystem /Users/MyUser/Qt/6.2.3/macos/lib/QtSql.framework/Headers/6.2.3/QtSql -isystem /Users/MyUser/Qt/6.2.3/macos/lib/QtSql.framework/Headers -g -DNDEBUG -O2 -arch x86_64 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -mmacosx-version-min=10.14 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -fno-exceptions -fapplication-extension -std=c++17 -MD -MT odbc/CMakeFiles/QODBCDriverPlugin.dir/qsql_odbc.cpp.o -MF odbc/CMakeFiles/QODBCDriverPlugin.dir/qsql_odbc.cpp.o.d -o odbc/CMakeFiles/QODBCDriverPlugin.dir/qsql_odbc.cpp.o -c /Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
                In file included from /Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers/odbc/qsql_odbc.cpp:40:
                In file included from /Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers/odbc/qsql_odbc_p.h:74:
                /Library/Frameworks/iODBC.framework/Headers/sql.h:89:10: fatal error: 'iODBC/sqltypes.h' file not found
                #include <iODBC/sqltypes.h>
                ^~~~~~~~~~~~~~~~~~
                1 error generated.
                [7/16] Building CXX object odbc/CMakeFiles/QODBCDriverPlugin.dir/main.cpp.o
                FAILED: odbc/CMakeFiles/QODBCDriverPlugin.dir/main.cpp.o
                /usr/bin/clang++ -DGL_SILENCE_DEPRECATION -DQODBCDriverPlugin_EXPORTS -DQT_CORE_LIB -DQT_DEPRECATED_WARNINGS -DQT_DEPRECATED_WARNINGS_SINCE=0x060000 -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_DEBUG -DQT_NO_EXCEPTIONS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_PLUGIN -DQT_SQL_LIB -DUNICODE -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I/Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers/odbc/QODBCDriverPlugin_autogen/include -I/Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers/odbc -I/Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers/include -isystem /Library/Frameworks/iODBC.framework/Headers -iframework /Users/MyUser/Qt/6.2.3/macos/lib -isystem /Users/MyUser/Qt/6.2.3/macos/lib/QtCore.framework/Headers -isystem /Users/MyUser/Qt/6.2.3/macos/mkspecs/macx-clang -isystem /Users/MyUser/Qt/6.2.3/macos/include -isystem /Users/MyUser/Qt/6.2.3/macos/lib/QtCore.framework/Headers/6.2.3 -isystem /Users/MyUser/Qt/6.2.3/macos/lib/QtCore.framework/Headers/6.2.3/QtCore -isystem /Users/MyUser/Qt/6.2.3/macos/lib/QtSql.framework/Headers/6.2.3 -isystem /Users/MyUser/Qt/6.2.3/macos/lib/QtSql.framework/Headers/6.2.3/QtSql -isystem /Users/MyUser/Qt/6.2.3/macos/lib/QtSql.framework/Headers -g -DNDEBUG -O2 -arch x86_64 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -mmacosx-version-min=10.14 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -fno-exceptions -fapplication-extension -std=c++17 -MD -MT odbc/CMakeFiles/QODBCDriverPlugin.dir/main.cpp.o -MF odbc/CMakeFiles/QODBCDriverPlugin.dir/main.cpp.o.d -o odbc/CMakeFiles/QODBCDriverPlugin.dir/main.cpp.o -c /Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers/odbc/main.cpp
                In file included from /Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers/odbc/main.cpp:42:
                In file included from /Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers/odbc/qsql_odbc_p.h:74:
                /Library/Frameworks/iODBC.framework/Headers/sql.h:89:10: fatal error: 'iODBC/sqltypes.h' file not found
                #include <iODBC/sqltypes.h>
                ^~~~~~~~~~~~~~~~~~
                1 error generated.
                [13/16] Building C object sqlite/CMakeFiles/QSQLiteDriverPlugin.dir/Users/MyUser/Qt/6.2.3/src/qtbase/src/3rdparty/sqlite/sqlite3.c.o
                ninja: build stopped: subcommand failed.s

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

                  Hi, if you get the errors when building the odbc and sqlite plugins, it doesn't matter since they come preinstalled in Qt 6.2.3 (i.e. you don't have to build them again).

                  But what about the mysql plugin? If you look in the folder /Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers/plugins/sqldrivers is there a libqsqlmysql.dylib there?

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mchinand
                    wrote on last edited by
                    #23

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

                    : /Library/Frameworks/iODBC.framework/Headers/sql.h:89:10: 'iODBC/sqltypes.h' file not found

                    This is a different library that uses the ODBC SDK, but looks to be the same issue. https://github.com/openlink/iODBC/issues/17

                    Perhaps, there is a CMake variable that you can set to false/OFF to disable building the ODBC plugin, but if the MySql plugin built then you should be good.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Achab61
                      wrote on last edited by
                      #24

                      @hskoglund, @mchinand : unfortunately, in the folder /Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers/plugins/sqldrivers there's no libqsqlmysql.dylib file.

                      Below is the snapshot of the /sqldrivers folder after running cmake --build .

                      Thanks for your help

                      Screenshot 2022-03-17 at 09.15.53.png

                      jsulmJ 1 Reply Last reply
                      0
                      • A Achab61

                        @hskoglund, @mchinand : unfortunately, in the folder /Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers/plugins/sqldrivers there's no libqsqlmysql.dylib file.

                        Below is the snapshot of the /sqldrivers folder after running cmake --build .

                        Thanks for your help

                        Screenshot 2022-03-17 at 09.15.53.png

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #25

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

                        after running cmake --build .

                        Did you also run

                        cmake --install .
                        

                        ?

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

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

                          Hi, note that are 2 different /sqldrivers folders in that path:

                          /Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers/plugins/sqldrivers
                          ........................................ one here ^       and one here ^
                          

                          Perhaps you're showing a snapshot of the first /sqldrivers folder?
                          The seond /sqldrivers folder should look something like this:
                          Screenshot 2022-03-17 at 10.20.40.png

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            Achab61
                            wrote on last edited by
                            #27

                            @hskoglund - /Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers/plugins/sqldrivers directory is empty

                            @jsulm - yes I tried, and this is what I got (it can't find libqsqlmysql.dylib):

                            -- Install configuration: "RelWithDebInfo"
                            -- Installing: /Users/MyUser/Qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfig.cmake
                            -- Installing: /Users/MyUser/Qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfigVersion.cmake
                            -- Installing: /Users/MyUser/Qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfigVersionImpl.cmake
                            CMake Error at mysql/cmake_install.cmake:49 (file):
                            file INSTALL cannot find
                            "/Users/MyUser/Qt/6.2.3/src/qtbase/src/plugins/sqldrivers/plugins/sqldrivers/libqsqlmysql.dylib":
                            No such file or directory.
                            Call Stack (most recent call first):
                            cmake_install.cmake:42 (include)ser

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

                              Hi, the build of the mysql plugin must have failed (hence no .dylib found)

                              You could try the build again, but first you need to delete all cmake cache files, easiest is just to delete the /sqldrivers directory (the first one, no the second one that's already empty).

                              Reinstall the sources for Qt 6,2.3 and try the qt-cmake command again (for simplicity and less problems, skip the Ninja and ...INSTALL_PREFIX options), so try something like this:
                              qt-cmake /Users/MyUser/Qt/6.2.3/Src/qtbase/src/plugins/sqldrivers -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
                              3
                              • A Offline
                                A Offline
                                Achab61
                                wrote on last edited by
                                #29

                                @hskoglund - I run the command you posted and this time in the folder :

                                /Users/MyUser/Qt/6.2.3/Src/qtbase/src/plugins/sqldrivers/plugins/sqldrivers there are the following file:

                                Screenshot 2022-03-18 at 08.51.50.png

                                However running: cmake --install . I still get the error about /libqsqlodbc.dylib but maybe the MySQL dirver should be ok now ?
                                What should I check ?

                                Thanks a lot for your support

                                -- Install configuration: "RelWithDebInfo"
                                -- Installing: /Users/MyUser/qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfig.cmake
                                -- Installing: /Users/MyUser/qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfigVersion.cmake
                                -- Installing: /Users/MyUser/qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfigVersionImpl.cmake
                                -- Installing: /Users/MyUser/qt/6.2.3/macos/./plugins/sqldrivers/libqsqlmysql.dylib
                                -- Installing: /Users/MyUser/qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginTargets.cmake
                                -- Installing: /Users/MyUser/qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginTargets-relwithdebinfo.cmake
                                -- Installing: /Users/MyUser/qt/6.2.3/macos/./plugins/sqldrivers/libqsqlmysql.dylib.dSYM
                                -- Installing: /Users/MyUser/qt/6.2.3/macos/./plugins/sqldrivers/libqsqlmysql.dylib.dSYM/Contents
                                -- Installing: /Users/MyUser/qt/6.2.3/macos/./plugins/sqldrivers/libqsqlmysql.dylib.dSYM/Contents/Resources
                                -- Installing: /Users/MyUser/qt/6.2.3/macos/./plugins/sqldrivers/libqsqlmysql.dylib.dSYM/Contents/Resources/DWARF
                                -- Installing: /Users/MyUser/qt/6.2.3/macos/./plugins/sqldrivers/libqsqlmysql.dylib.dSYM/Contents/Resources/DWARF/qsqlmysql
                                -- Installing: /Users/MyUser/qt/6.2.3/macos/./plugins/sqldrivers/libqsqlmysql.dylib.dSYM/Contents/Info.plist
                                -- Installing: /Users/MyUser/qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginAdditionalTargetInfo.cmake
                                -- Installing: /Users/MyUser/qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QODBCDriverPluginConfig.cmake
                                -- Installing: /Users/MyUser/qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QODBCDriverPluginConfigVersion.cmake
                                -- Installing: /Users/MyUser/qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QODBCDriverPluginConfigVersionImpl.cmake
                                CMake Error at odbc/cmake_install.cmake:49 (file):
                                file INSTALL cannot find
                                "/Users/MyUser/qt/6.2.3/Src/qtbase/src/plugins/sqldrivers/plugins/sqldrivers/libqsqlodbc.dylib":
                                No such file or directory.
                                Call Stack (most recent call first):
                                cmake_install.cmake:47 (include)

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

                                  Hi, you can install libqsqlmysql.dylib manually, just copy it from /Users/MyUser/Qt/6.2.3/Src/qtbase/src/plugins/sqldrivers/plugins/sqldrivers to /Users/MyUser/Qt/6.2.3/macos/plugins/sqldrivers and you should be fine :-)

                                  1 Reply Last reply
                                  1
                                  • A Offline
                                    A Offline
                                    Achab61
                                    wrote on last edited by
                                    #31

                                    @hskoglund - Thank you very much for your great assistance !

                                    Unfortunately it seems that the driver is not recognized by python (pyQt5) as I still get the error:

                                    QSqlDatabase: QMYSQL driver not loaded
                                    QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
                                    QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins

                                    I tried also to follow the the instructions included in this post:

                                    https://forum.qt.io/topic/106565/mysql-qt-create-plugin-mysql-for-qt-on-mac/2

                                    but the 'install_name_tool -change' command mentioned is just displaying the help menu.

                                    I think it's maybe better to change the db ....

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

                                      pyQt5 if it's based on Qt5 then the MySql plugin for Qt6 you just built will not work (plugins for Qt6 does not work in Qt5). Perhaps you need to upgrade to pyQt6...

                                      1 Reply Last reply
                                      0
                                      • D DeadSo0ul 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