Qt Installation issues on windows
-
I have been trying to install Qt on my windows 10 laptop. I originally downloaded the online installer and used it to get Qt & Qt creator, but I was not able to add a plugin that I needed QtSQL: mysql. Hence, now I have changed to trying to build from the source code, I am using v6.8.0-beta1 tag for the source code download. I needed it to ensure that I get init-repository.bat so I can stick to windows build environments.
So I have tried to make it work, I have the environment set up: Cmake, Ninja, MSVC 2022, MSVC 2019 and MinGW. MinGW is from https://github.com/niXman/mingw-builds-binaries/releases; Release of 13.2.0-rt_v11-rev0; File x86_64-13.2.0-release-win32-seh-msvcrt-rt_v11-rev0.7z. This has given me version 13.2.0 for MinGW. I have also set up both MSVC 2022 and 2019 with amd64 so they have the build environment of x64. When I try to build it, it doesn't work:
C:\Qt>cmake --build . [26/11645] Linking CXX executable qtbase\bin\syncqt.exe FAILED: qtbase/bin/syncqt.exe C:\Windows\system32\cmd.exe /C "cd . && C:\MinGW\bin\c++.exe -DNDEBUG -O3 -fexceptions qtbase/src/tools/syncqt/CMakeFiles/syncqt.dir/syncqt_resource.rc.obj qtbase/src/tools/syncqt/CMakeFiles/syncqt.dir/main.cpp.obj qtbase/src/tools/syncqt/CMakeFiles/syncqt.dir/syncqt_longpath.rc.obj -o qtbase\bin\syncqt.exe -Wl,--out-implib,qtbase\src\tools\syncqt\libsyncqt.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ." C:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: i386 architecture of input file `qtbase/src/tools/syncqt/CMakeFiles/syncqt.dir/syncqt_resource.rc.obj' is incompatible with i386:x86-64 output C:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: i386 architecture of input file `qtbase/src/tools/syncqt/CMakeFiles/syncqt.dir/syncqt_longpath.rc.obj' is incompatible with i386:x86-64 output collect2.exe: error: ld returned 1 exit status [43/11645] Building C object qtbase/src/3rdparty/libjpeg/CMakeFiles/BundledLibjpeg.dir/jdhuff.c.obj ninja: build stopped: subcommand failed.
Any advise of how I can get the qt mysql driver to work either with the beta build or any other way on windows 10 x64 to work is appreciated.
-
Why do you compile Qt when you only need the mysql plugin? Follow the documentation: https://doc.qt.io/qt-6/sql-driver.html#how-to-build-the-qmysql-plugin-on-unix-and-macos
-
You also have to use the same Qt source version and compiler as you do for your program. Mixing MinGW and MSVC will not work.
For reference - SO told you exactly the same: https://stackoverflow.com/questions/78733956/how-to-resolve-architecture-incompatibility-errors-when-building-qt-from-source -
@Christian-Ehrlicher
That is me :'), thought it was best to post in both communities, so that I hv a better chance of making it work somehow : D.I did follow the guide for mysql from qt. The instructions for windows are sparse and often quite hard to understand. I did manage to get it configure to
Qt Sql Drivers:
MySql .................................. yes
at some point, but I am not there anymore. Tried different ways as I wasn't able to build.I have updated on the stackoverflow post some more of what I tried before. I'll do the same here. It's not letting me 😶 marking it as spam
-
I have rewritten it all here:
I have been trying to install Qt on my Windows 10 laptop. I originally downloaded the online installer and used it to get Qt and Qt Creator, but I was not able to add a plugin that I needed: QtSQL: mysql.
Hence, now I have changed to trying to build from the source code, I am using v6.8.0-beta1 tag for the source code download. I needed it to ensure that I get
init-repository.bat
, so I can stick to Windows build environments.So I have tried to make it work, I have the environment set up: CMake, Ninja, MSVC 2022, MSVC 2019 and MinGW. MinGW is from GitHub — niXman — mingw-builds-binaries — Release of 13.2.0-rt_v11-rev1; File
x86_64-13.2.0-release-win32-seh-msvcrt-rt_v11-rev0.7z
. This has given me version 13.2.0 for MinGW.I have also set up both MSVC 2022 and 2019 with amd64, so they have the build environment of x64.
To build, I ran this command:
git clone --branch v6.8.0-beta1 code.qt.io/qt/qt5.git Qt
Then:
configure -init-submodules
When I try to run
cmake --build
, both with and without--parallel
, it gives me this error:C:\Qt>cmake --build . [26/11645] Linking CXX executable qtbase\bin\syncqt.exe FAILED: qtbase/bin/syncqt.exe C:\Windows\system32\cmd.exe /C "cd . && C:\MinGW\bin\c++.exe -DNDEBUG -O3 -fexceptions qtbase/src/tools/syncqt/CMakeFiles/syncqt.dir/syncqt_resource.rc.obj qtbase/src/tools/syncqt/CMakeFiles/syncqt.dir/main.cpp.obj qtbase/src/tools/syncqt/CMakeFiles/syncqt.dir/syncqt_longpath.rc.obj -o qtbase\bin\syncqt.exe -Wl,--out-implib,qtbase\src\tools\syncqt\libsyncqt.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ." C:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: i386 architecture of input file `qtbase/src/tools/syncqt/CMakeFiles/syncqt.dir/syncqt_resource.rc.obj' is incompatible with i386:x86-64 output C:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: i386 architecture of input file `qtbase/src/tools/syncqt/CMakeFiles/syncqt.dir/syncqt_longpath.rc.obj' is incompatible with i386:x86-64 output collect2.exe: error: ld returned 1 exit status [43/11645] Building C object qtbase/src/3rdparty/libjpeg/CMakeFiles/BundledLibjpeg.dir/jdhuff.c.obj ninja: build stopped: subcommand failed.
How can I get the Qt mysql driver to work either with the beta build or any other way on Windows 10 x64 to work?
Previous Tries:
- I had originally downloaded from the online installer with qt 6.7.2. I tried to initialize the MySQL drivers from various ways, first from the MySQL c++ connector. That didn't work, I tried to do it with the Qt SQL driver but that was not working because for some reason, probably because
Qt\----\mingw\plugins\sqldrivers
was empty. - I tried again with
6.5.3
and it still still didn't work. - I tried with
6.6.3
and sqldrivers was not empty this time. The initialization of MySQL followingC:\Qt\6.0.0\Src\configure.bat -sql-mysql -- -DMySQL_INCLUDE_DIR="C:\mysql-8.0.22-winx64\include" -DMySQL_LIBRARY="C:\mysql-8.0.22-winx64\lib\libmysql.lib"
worked, but then the build process did not work no matter which MinGW I used. - I did next time from source with
v6.6.0
.init-repository
withperl
and build was again not working.
After these, I thought it might be due to the environment, so I tried to do it without
perl
which is only in the dev branch and inv6.8.0-beta1
which containsinit-repository.bat
which I thought might have been the solutions to my problems as I found on another post thatperl
has its own environment. And then I am here after ensuring that I have the right basic environment, or so I assume.Update:
I removed 6.8.0-beta1 and downloaded 6.7.2. Ranperl init-repository
andcmake --build . --parallel
followed withcmake --install .
.Initially, I tried to initialize the sql driver using
configure.bat -sql-mysql -- -DMySQL_INCLUDE_DIR="C:\MySQL\MySQL Server 8.0\include" -DMySQL_LIBRARY="C:\MySQL\MySQL Server 8.0\lib\libmysql.lib"
and
call "C:\Qt\6.7.2\qtbase\bin\qt-cmake.bat" C:\Qt\6.7.2\qtbase\src\plugins\sqldrivers -DMySQL_INCLUDE_DIR="C:\MySQL\MySQL Server 8.0\include" -DMySQL_LIBRARY="C:\MySQL\MySQL Server 8.0\lib\libmysql.lib"
Neither worked, the second command gave me this error as part of it's output:
CMake Error at qtbase/cmake/QtBuildInformation.cmake:522 (message): Feature "sql_mysql": Forcing to "ON" breaks its condition: MySQL_FOUND Condition values dump: MySQL_FOUND = "FALSE" Call Stack (most recent call first): qtbase/cmake/QtFeature.cmake:322 (qt_configure_add_report_error) qtbase/cmake/QtFeature.cmake:442 (qt_feature_check_and_save_internal_value) qtbase/cmake/QtFeature.cmake:711 (qt_evaluate_feature) qtbase/src/plugins/sqldrivers/CMakeLists.txt:44 (qt_feature_module_end) -- Configuring submodule 'qtimageformats' -- Check if compiler accepts -pthread -- Check if compiler accepts -pthread - yes CMake Error at qtbase/lib/cmake/Qt6BuildInternals/QtBuildInternalsExtra.cmake:151 (set): Syntax error in cmake code at C:/Qt/6.7.2/qtbase/lib/cmake/Qt6BuildInternals/QtBuildInternalsExtra.cmake:151 when parsing string MySQL_INCLUDE_DIR=C:\MySQL\MySQL Server 8.0\include;MySQL_LIBRARY=C:\MySQL\MySQL Server 8.0\lib\libmysql.lib Invalid character escape '\M'. Call Stack (most recent call first): qtbase/lib/cmake/Qt6BuildInternals/Qt6BuildInternalsConfig.cmake:11 (include) qtbase/lib/cmake/Qt6/Qt6Config.cmake:169 (find_package) qtimageformats/CMakeLists.txt:14 (find_package) -- Configuring incomplete, errors occurred! CMake Error at qtbase/cmake/QtProcessConfigureArgs.cmake:1077 (message): CMake exited with code 1.
After this as I mentioned, I ran a simple
configure
. I can't find any mysql in the build directory.Update 2:
I reran the first commandconfigure.bat -sql-mysql -- -DMySQL_INCLUDE_DIR="C:\MySQL\MySQL Server 8.0\include" -DMySQL_LIBRARY="C:\MySQL\MySQL Server 8.0\lib\libmysql.lib"
.When I ran
cmake --build . --parallel
I got the following error log:C:\Qt\6.7.2>cmake --build . --parallel [2/2163] Building RC object qtbase/src/plugins/sqldrivers/mysql/CMakeFiles/QMYSQLDriverPlugin.dir/QMYSQLDriverPlugin_resource.rc.obj FAILED: qtbase/src/plugins/sqldrivers/mysql/CMakeFiles/QMYSQLDriverPlugin.dir/QMYSQLDriverPlugin_resource.rc.obj C:\MinGW\bin\windres.exe -O coff -DMINGW_HAS_SECURE_API=1 -DNOMINMAX -DQMYSQLDriverPlugin_EXPORTS -DQT_CORE_LIB -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_UP_TO=0x040800 -DQT_EXPLICIT_QFILE_CONSTRUCTION_FROM_PATH -DQT_LEAN_HEADERS=1 -DQT_NO_AS_CONST -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_CONTEXTLESS_CONNECT -DQT_NO_DEBUG -DQT_NO_EXCEPTIONS -DQT_NO_FOREACH -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_QEXCHANGE -DQT_PLUGIN -DQT_SQL_LIB -DQT_USE_QSTRINGBUILDER -DQT_WARN_DEPRECATED_UP_TO=0x070000 -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_UNICODE -D_WIN64 -I C:/Qt/6.7.2/qtbase/src/plugins/sqldrivers/mysql/QMYSQLDriverPlugin_autogen/include -I C:/Qt/6.7.2/qtbase/src/plugins/sqldrivers/mysql -I C:/Qt/6.7.2/qtbase/include -I C:/Qt/6.7.2/qtbase/include/QtCore -I C:/Qt/6.7.2/qtbase/mkspecs/win32-g++ -I C:/Qt/6.7.2/qtbase/src/corelib -I C:/Qt/6.7.2/qtbase/include/QtCore/6.7.2 -I C:/Qt/6.7.2/qtbase/include/QtCore/6.7.2/QtCore -I C:/Qt/6.7.2/qtbase/src/sql -I C:/Qt/6.7.2/qtbase/include/QtSql/6.7.2 -I C:/Qt/6.7.2/qtbase/include/QtSql/6.7.2/QtSql -I C:/Qt/6.7.2/qtbase/include/QtSql -I "C:/MySQL/MySQL Server 8.0/include" C:/Qt/6.7.2/qtbase/src/plugins/sqldrivers/mysql/QMYSQLDriverPlugin_resource.rc qtbase/src/plugins/sqldrivers/mysql/CMakeFiles/QMYSQLDriverPlugin.dir/QMYSQLDriverPlugin_resource.rc.obj cc1.exe: fatal error: Server\: No such file or directory compilation terminated. cc1.exe: fatal error: 8.0/include: No such file or directory compilation terminated. C:\MinGW\bin\windres.exe: preprocessing failed. [19/2163] Building CXX object qtbase/src/plugins/platforms/direct2d/CMakeFiles/QWindowsDirect2DIntegrationPlugin.dir/__/windows/qwindowsdialoghelpers.cpp.obj ninja: build stopped: subcommand failed.
- I had originally downloaded from the online installer with qt 6.7.2. I tried to initialize the MySQL drivers from various ways, first from the MySQL c++ connector. That didn't work, I tried to do it with the Qt SQL driver but that was not working because for some reason, probably because
-
Stop building the whole qt when you just need to build the mysql plugin. Install the Qt sources in the same version as your binaries with the help of the online installer, use the same compiler, don't download another mingw compiler for unknown reasons, and follow the instructions. Not that hard...
/edit: and make sure there are no spaces in the path or properly quote them - windows does not like spaces in paths.
-
@Christian-Ehrlicher Hey, I removed everything and downloaded only the given perset for qt development for desktop. Then I used the maintenance tool to add sources. After which I have run two commands with the following outputs:
C:\Qt\6.7.2\Src>call C:\Qt\6.7.2\mingw_64\bin\qt-cmake -G Ninja C:\Qt\6.7.2\Src\qtbase\src\plugins\sqldrivers -DMySQL_INCLUDE_DIR="C:\MySQL\MySQL Server 8.0\include" -DMySQL_LIBRARY=C:\MySQL\MySQL Server 8.0\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\6.7.2\mingw_64" CMake Warning: Ignoring extra path from command line: "8.0\lib\libmysql.lib -DCMAKE_INSTALL_PREFIX=C:\Qt\6.7.2\mingw_64" -- The CXX compiler identification is GNU 13.2.0 -- The C compiler identification is GNU 13.2.0 -- The ASM compiler identification is GNU -- Found assembler: C:/MinGW/bin/gcc.exe -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: C:/MinGW/bin/c++.exe - 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: C:/MinGW/bin/gcc.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Check if compiler accepts -pthread -- Check if compiler accepts -pthread - yes -- Found Threads: TRUE -- Performing Test HAVE_STDATOMIC -- Performing Test HAVE_STDATOMIC - Success -- Found WrapAtomic: TRUE -- Force setting build type to 'RelWithDebInfo'. -- Configuration summary shown below. It has also been written to C:/Qt/6.7.2/Src/config.summary -- Configure with --log-level=STATUS or higher to increase CMake's message verbosity. The log level does not persist across reconfigurations. -- 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 Mimer .................................. no -- Configuring done (6.9s) -- Generating done (0.2s) -- Build files have been written to: C:/Qt/6.7.2/Src
The second command, I renamed the folder to remove the spaces:
C:\Qt\6.7.2\Src>call C:\Qt\6.7.2\mingw_64\bin\qt-cmake -G Ninja C:\Qt\6.7.2\Src\qtbase\src\plugins\sqldrivers -DMySQL_INCLUDE_DIR="C:\MySQL\MySQL_Server_8.0\include" -DMySQL_LIBRARY=C:\MySQL\MySQL_Server_8.0\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\6.7.2\mingw_64" -- Configuration summary has been written to C:/Qt/6.7.2/Src/config.summary -- Configuring done (1.5s) -- Generating done (0.3s) CMake Warning: Manually-specified variables were not used by the project: CMAKE_TOOLCHAIN_FILE -- Build files have been written to: C:/Qt/6.7.2/Src
After that, I tried to build it:
C:\Qt\6.7.2\Src>cmake --build . --parallel ninja: error: FindFirstFileExA(C:/MySQL/MySQL_Server_8.0/lib/libmysql.lib -DCMAKE_INSTALL_PREFIX=C:/Qt/6.7.2): The filename, directory name, or volume label syntax is incorrect.
Do I not need to build it? Or I did something wrong?
-
Hi, when you change MySQL's folder name from MySQL Server 8.0 to MySQL_Server_8.0, for this to be visible for the build, I think you need to start over at step #1 (i..e. remove everything and download C:\Qt\6.7.2\Src\qtbase\src\plugins\sqldrivers again).
-
-DMySQL_LIBRARY=C:\MySQL\MySQL Server 8.0\lib\libmysql.lib"
As cmake tells you there is something wrong and you simply ignored it - you miss a " after the = as you correctly did for the other variable...
-
😅 I didn't notice that when running the command. Well, I have fixed it. I ran
cmake --build . --parallel
and thencmake --install .
Do I need to run anything else @Christian-Ehrlicher ? Any are there any resources on understanding how to best use QtSQL or specifically MySQL?
Also thx @hskoglund .
In case anyone else comes here, don't move the folders for MySQL, just uninstall it and reinstall at desired place or do using zip files somehow. It broke MySQL on my side :'). Got it fixed now :). -
No need to move anything when the path is properly quoted. An easier way would be to simply use postgresql - this driver is available directly as plugin.
There is nothing really special when using Qt Sql - see https://doc.qt.io/qt-6/sql-programming.html there are also some examples in there. -
@Christian-Ehrlicher Tysm! Hv a great day!
-