building Qt MYSQL driver for MAC OS Monterey
-
@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>
@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. -
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
-
Hi,
Delete the build folder where you tried first and start from scratch.
-
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
-
@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. -
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** -
Looks like the content of MySQL_LIBRARY contains something wrong. Can you share the exact command you used ?
-
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>”
-
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 -
@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/sqldriversNow I'm facing (maybe..) another issue: in the documentation it's reported run the following commands:
cmake --build
cmake --installBut when I type cmake --build I get the cmake --build help menu and I don't know why.
Thanks for any hintHere below the screenshot of the /sqldrivers and /sqldrivers/mysql folders
-
You forgot the dot after the command.
cmake --build . cmake --install .
It's not punctuation in this case ;-)
-
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.
-
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 -
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? -
@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.
-
@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
-
@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
@Achab61 said in building Qt MYSQL driver for MAC OS Monterey:
after running cmake --build .
Did you also run
cmake --install .
?