Код:
#include <QtWidgets>
#include <QtSql>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication App(argc,argv);
MainWindow *Window = new MainWindow;
Window->show();
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL","mydb");
db.setHostName("localhost");
db.setDatabaseName("institute");
db.setUserName("root");
db.setPassword("1234");
bool ok = db.open();
int result = App.exec();
delete Window;
return result;
}
Компилятор:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
В книге вот что нашел:
Не факт, что из-за этого, но все-таки не понятно, куда этот код писать? Вот этот код:
configure -plugin-sql-mysql -I C:\Program Files\MySQL\MySQL Server 5.7\include -L C:\Program Files\MySQL\MySQL Server 5.7\lib
Видимо точно не в pro-файл
CRUD API на C# и GraphQL
stackOverflow 05.05.2025
В бэкенд-разработке постоянно возникают новые технологии, призванные решить актуальные проблемы и упростить жизнь программистам. Одной из таких технологий стал GraphQL — язык запросов для API,. . .
Распознавание голоса и речи на C#
UnmanagedCoder 05.05.2025
Интеграция голосового управления в приложения на C# стала намного доступнее благодаря развитию специализированных библиотек и API. При этом многие разработчики до сих пор считают голосовое управление. . .
Реализация своих итераторов в C++
NullReferenced 05.05.2025
Итераторы в C++ — это абстракция, которая связывает весь экосистему Стандартной Библиотеки Шаблонов (STL) в единое целое, позволяя алгоритмам работать с разнородными структурами данных без знания их. . .
Разработка собственного фреймворка для тестирования в C#
UnmanagedCoder 04.05.2025
C# довольно богат готовыми решениями – NUnit, xUnit, MSTest уже давно стали своеобразными динозаврами индустрии. Однако, как и любой динозавр, они не всегда могут протиснуться в узкие коридоры. . .
Распределенная трассировка в Java с помощью OpenTelemetry
Javaican 04.05.2025
Микросервисная архитектура стала краеугольным камнем современной разработки, но вместе с ней пришла и головная боль, знакомая многим — отслеживание прохождения запросов через лабиринт взаимосвязанных. . .
Шаблоны обнаружения сервисов в Kubernetes
Mr. Docker 04.05.2025
Современные Kubernetes-инфраструктуры сталкиваются с серьёзными вызовами. Развертывание в нескольких регионах и облаках одновременно, необходимость обеспечения низкой задержки для глобально. . .
Создаем SPA на C# и Blazor
stackOverflow 04.05.2025
Мир веб-разработки за последние десять лет претерпел коллосальные изменения. Переход от традиционных многостраничных сайтов к одностраничным приложениям (Single Page Applications, SPA) — это. . .
Реализация шаблонов проектирования GoF на C++
NullReferenced 04.05.2025
«Банда четырёх» (Gang of Four или GoF) — Эрих Гамма, Ричард Хелм, Ральф Джонсон и Джон Влиссидес — в 1994 году сформировали канон шаблонов, который выдержал проверку временем. И хотя C++ претерпел. . .
C# и сети: Сокеты, gRPC и SignalR
UnmanagedCoder 04.05.2025
Сетевые технологии не стоят на месте, а вместе с ними эволюционируют и инструменты разработки. В . NET появилось множество решений — от низкоуровневых сокетов, позволяющих управлять каждым байтом. . .
Создание микросервисов с Domain-Driven Design
ArchitectMsa 04.05.2025
Архитектура микросервисов за последние годы превратилась в мощный архитектурный подход, который позволяет разрабатывать гибкие, масштабируемые и устойчивые системы. А если добавить сюда ещё и. . .
При компиляции проекта в Windows 10 в Qt5, связанного с MySQL, появляется ошибка:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
Далее проверяем действительно ли отсутствует драйвер MySql.
В .pro файле прописываем
QT + = sql
и добавляем
#include <QSqlDatabase> #include <QDebug> qDebug()<< QSqlDatabase::drivers();
Получаем вывод:
(«QSQLITE», «QODBC», «QODBC3», «QPSQL», «QPSQL7»)
Драйвер MySql отсутствует.
В итоги, ошибка связана с тем, что отсутствует драйвер MYSQL и его необходимо скомпилировать самостоятельно из исходников mysql
C:\Qt\Qt5.12.12\5.12.12\Src\qtbase\src\plugins\sqldrivers\mysql
Если отсутствует папка Source, устанавливаем через MaintenanceTool.exe (C:\Qt\Qt5.12.12).
Устанавливаем пакет MYSQL — mysql-installer-community-8.0.32.0.msi и пакет MySQL Connector C 6.1
Устанавливаем в переменные среды Path
C:\Qt\Qt5.12.12\5.12.12\mingw73_64\bin, где лежит qmake.exe
C:\Qt\Qt5.12.12\Tools\mingw730_64\bin, где лежит mingw32-make.exe
C:\Program Files\MySQL\MySQL Connector C 6.1\lib
Состояние переменной среды можно посмотреть командой строке MinGW 7.3.0.64-bit
echo %PATH%
1 способ
Добавим пути в программе Qt Creator к библиотеки MySQL
Нажимаем правой клавишей мыши по проекту и открывается меню и жмём Добавить библиотеку
Тип библиотеки — внешняя и Далее
Снимаем галочки с Linux, Mac и жмём файл библиотеки и указываем путь C:\Program Files\MySQL\MySQL Server 8.0\lib к библиотеки libmysql.lib
Жмем Далее и Завершить.
Файл .pro станет выглядеть так
TARGET = qsqlmysql HEADERS += $$PWD/qsql_mysql_p.h SOURCES += $$PWD/qsql_mysql.cpp $$PWD/main.cpp #QMAKE_USE += mysql win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../../../../../../Program Files/MySQL/MySQLServer/lib/' -llibmysql else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/'../../../../../../../../../Program Files/MySQL/MySQLServer/lib/' -llibmysqld INCLUDEPATH += $$PWD/'../../../../../../../../../Program Files/MySQL/MySQLServer/include' DEPENDPATH += $$PWD/'../../../../../../../../../Program Files/MySQL/MySQLServer/include' OTHER_FILES += mysql.json PLUGIN_CLASS_NAME = QMYSQLDriverPlugin #include(../qsqldriverbase.pri)
Если во время компиляции появится ошибки
Cannot read C:/Qt/Qt5.12.12/5.12.12/Src/qtbase/src/plugins/sqldrivers/qtsqldrivers-config.pri: No such file or directory
или
Project ERROR: Library ‘mysql’ is not defined.
нужно закомментировать строчки
#QMAKE_USE += mysql
#include(../qsqldriverbase.pri)
После компиляции в директории
C:\Qt\Qt5.12.12\5.12.12\Src\qtbase\src\plugins\sqldrivers\plugins\sqldrivers
появятся файлы
libqsqlmysql.a, libqsqlmysqld.a, qsqlmysql.dll, qsqlmysqld.dll
и копируем их в папку
C:\Qt\Qt5.12.12\5.12.12\mingw73_64\plugins\sqldrivers
2 способ
Устанавливаем MySQL Connector C 6.1 и желательно ставить не в папку Program Files, а в отдельную. Открываем исходник MySQL и в файле .pro в ручную прописываем пути к библиотеки MySQL.
TARGET = qsqlmysql HEADERS += $$PWD/qsql_mysql_p.h SOURCES += $$PWD/qsql_mysql.cpp $$PWD/main.cpp #QMAKE_USE += mysql #LIBS += -LC:\Program Files\MySQL\MySQL Connector C 6.1\lib #-lmysql #win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../../../../../../Program Files/MySQL/MySQL Connector C 6.1/lib/' -llibmysql #else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/'../../../../../../../../../Program Files/MySQL/MySQL Connector C 6.1/lib/' -llibmysqld #INCLUDEPATH += $$PWD/'../../../../../../../../../Program Files/MySQL/MySQL Connector C 6.1/include' #DEPENDPATH += $$PWD/'../../../../../../../../../Program Files/MySQL/MySQL Connector C 6.1/include' OTHER_FILES += mysql.json PLUGIN_CLASS_NAME = QMYSQLDriverPlugin #include(../qsqldriverbase.pri) INCLUDEPATH += "C:\MySQLConnector6\include" LIBS +="C:\MySQLConnector6\lib\libmysql.lib" DESTDIR = ../mysql/lib/
компилируем и в папке
C:\Qt\Qt5.12.12\5.12.12\Src\qtbase\src\plugins\sqldrivers\plugins\sqldrivers
появятся файлы
и копируем их в директорию
C:\Qt\Qt5.12.12\5.12.12\mingw73_64\plugins\sqldrivers
И также файл libmysql.dll и libmysql.lib копируем из директории
C:\MySQLConnector6\lib
в директорию
C:\Qt\Qt5.12.12\5.12.12\mingw73_64\bin
3 способ
Устанавливаем MySQL Connector C 6.1 и запускаем командную строку в
Переходим в папку
cd C:\Qt\Qt5.12.12\5.12.12\Src\qtbase\src\plugins\sqldrivers\mysql
и вводим
qmake — MYSQL_INCDIR=C:/MySQLConnector6/include/ MYSQL_LIBDIR=C:/MySQLConnector6/lib
mingw32-make.exe
и в директории
C:\Qt\Qt5.12.12\5.12.12\Src\qtbase\src\plugins\sqldrivers\plugins\sqldrivers
получаем файлы
- Forum
- Qt
- Newbie
- QSqlDatabase: QMYSQL driver not loaded but available
-
QSqlDatabase: QMYSQL driver not loaded but available
Yeah hello there, I’m really new here.
So here’s the problem.QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
To copy to clipboard, switch view to plain text mode
I’ve checked many forums already and have done things so far:
1) This is my .pro fileQT += core
QT += sql
QT -= gui
TARGET = DB
CONFIG += console
CONFIG -= app_bundle
QTPLUGIN += QSQLMYSQL
TEMPLATE = app
SOURCES += main.cpp
To copy to clipboard, switch view to plain text mode
2) This is my sqldrivers folder:
alex@alex-Laptop:~/Programming/Qt/5.1.0/gcc_64/plugins/sqldrivers$ ls
libqsqlite.so libqsqlmysql.so libqsqlpsql.so
To copy to clipboard, switch view to plain text mode
3) Have also copied sqldrivers folder to project folder.
Non of these helped an error still exists.
I have read almost everything about my problem but nothing helped.
Please help newbie with the fix.Thanks in advance
-
Re: QSqlDatabase: QMYSQL driver not loaded but available
post the part of the code where you open the database connection
-
Re: QSqlDatabase: QMYSQL driver not loaded but available
db.setHostName("teachinglessons.abcz8.com");
db.setPort(3306);
db.setDatabaseName("teachi4_test");
db.setUserName("alex");
db.setPassword("123");
qDebug()<<db.open();
To copy to clipboard, switch view to plain text mode
-
Re: QSqlDatabase: QMYSQL driver not loaded but available
Try giving the database a name:
db = QSqlDatabase::addDatabase("QMYSQL", "my_sql_db");
To copy to clipboard, switch view to plain text mode
Plus, have you built the plugins?
http://harmattan-dev.nokia.com/docs/…x-and-mac-os-x
-
Re: QSqlDatabase: QMYSQL driver not loaded but available
Nothing change unfortunately
-
Re: QSqlDatabase: QMYSQL driver not loaded but available
Read my editing, i think you are missing the step of building the plugins
-
Re: QSqlDatabase: QMYSQL driver not loaded but available
Originally Posted by KillGabio
Read my editing, i think you are missing the step of building the plugins
There’s no /src/plugins/sqldrivers/mysql in my qt folder should i create it?
Sorry for stupid question
-
Re: QSqlDatabase: QMYSQL driver not loaded but available
I have this path for example:
C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\my sqls
containing main.cpp, mysql.pro and readme.
Im running on windows, but you should have the same path i assume. Somewhere you need to have the files to generate and build your drivers.
-
Re: QSqlDatabase: QMYSQL driver not loaded but available
You have the Qt plugin for MySQL and it is recognised far enough to tell your program it exists. Are the MySQL run-time libraries (on which an actual database connection would depend) available on your machine?
-
12th July 2013, 09:06
#10
Re: QSqlDatabase: QMYSQL driver not loaded but available
KillGabio
There’s nothing like that found in my QtChrisW67
Yes but same problem
-
12th July 2013, 09:28
#11
Re: QSqlDatabase: QMYSQL driver not loaded but available
On Windows when I had the same problem i had to include the .dll of the database in this path:
C:\QtSDK\Desktop\Qt\4.8.1\mingw\plugins\sqldrivers
So that the compiler knows the libraries. For example there I have: qsqlite4.dll, qsqlocid4.dll, etc. I think you are missing the same files but for Unix (.so shared objects)
-
12th July 2013, 09:31
#12
Re: QSqlDatabase: QMYSQL driver not loaded but available
alex@alex-Laptop:~/Programming/Qt/5.1.0/gcc_64/plugins/sqldrivers$ ls
libqsqlite.so libqsqlmysql.so libqsqlpsql.so
I have the libraries there
-
12th July 2013, 11:11
#13
Re: QSqlDatabase: QMYSQL driver not loaded but available
Those are the Qt plugins, not the MySQL runtime libraries. You are looking for libmysqlclient.so somewhere on your system.
-
12th July 2013, 16:53
#14
Re: QSqlDatabase: QMYSQL driver not loaded but available
Originally Posted by ChrisW67
Those are the Qt plugins, not the MySQL runtime libraries. You are looking for libmysqlclient.so somewhere on your system.
Yeah I found them. What should I do with them?
locaalex@alex-Laptop:~$ locate libmysqlclient.so
/usr/lib/i386-linux-gnu/libmysqlclient.so.18
/usr/lib/i386-linux-gnu/libmysqlclient.so.18.0.0
/usr/lib/x86_64-linux-gnu/libmysqlclient.so
/usr/lib/x86_64-linux-gnu/libmysqlclient.so.18
/usr/lib/x86_64-linux-gnu/libmysqlclient.so.18.0.0
To copy to clipboard, switch view to plain text mode
-
12th July 2013, 19:25
#15
Re: QSqlDatabase: QMYSQL driver not loaded but available
Include them in your .pro. Example:
INCLUDEPATH += "C:/oraclexe/app/oracle/product/11.2.0/server/oci/lib/MSVC/vc10"
LIBS += -L"C:/Qt/Los taninos-killgabio/qextserialport/build" -lqextserialportd
To copy to clipboard, switch view to plain text mode
-
12th July 2013, 20:42
#16
Re: QSqlDatabase: QMYSQL driver not loaded but available
Originally Posted by alexandrius
Yeah I found them. What should I do with them?
Nothing , they should be in a default library search location for the system.
What is the result when you run:
$ ldd ~/Programming/Qt/5.1.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so
To copy to clipboard, switch view to plain text mode
Are there any libraries reported missing? You might try this:
$ objdump -x /home/chrisw/Qt5.1.0/5.1.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so | grep NEEDED
To copy to clipboard, switch view to plain text mode
Does it show the same version number on the mysql related line as in your libs64 folder?
Last edited by ChrisW67; 12th July 2013 at 20:50.
-
The following user says thank you to ChrisW67 for this useful post:
adutzu89 (17th December 2013)
-
30th July 2013, 17:17
#17
Re: QSqlDatabase: QMYSQL driver not loaded but available
I’m reviving this thread as it seems to be inactive without a answer to the problem and I was dealing with exactly the same problem for the past few days.
(with Opensuse 12.3, x86_64).it seems that the compiled plugin that comes with the qt (qt-linux-opensource-5.1.0-x86_64-offline.bin) requires /usr/lib64/libmysqlclient_r.so.16 and opensuse comes with .18. So
doing
/usr/lib64 # ln -s libmysqlclient_r.so libmysqlclient_r.so.16seems to solve the problem.
regards,
-
The following user says thank you to artome for this useful post:
adutzu89 (17th December 2013)
-
3rd March 2014, 16:57
#18
Re: QSqlDatabase: QMYSQL driver not loaded but available
/usr/lib/i386-linux-gnu$ ln -s libmysqlclient_r.so libmysqlclient_r.so.16
Fixed my problem
Thanks,
Selva
-
The following user says thank you to tselvakumars for this useful post:
martonmiklos (6th July 2014)
-
Re: QSqlDatabase: QMYSQL driver not loaded but available
I have had the similar problem on Kubuntu 14.04 64 bit with the latest 5.3.1 Qt relase downloaded from the qt-project and installed to the /opt.
The Ubuntu 14.04 ships with libmysqlclient 18 while the Qt 5.3.1 is built with 16. So the creating of a symlink like above did not solved my issue.
Finally I have downloaded the libmysqlclient 16 from here:
http://packages.ubuntu.com/lucid/amd…ent16/downloadAnd extraceted the library files to my /usr/lib/x86_64-linux-gnu folder.
-
29th March 2016, 08:38
#20
Re: QSqlDatabase: QMYSQL driver not loaded but available
Had the same problem => Plugin QMYSQL & QMYSQL 3 were available but couldn’t load them :
«QSqlDatabase: QMYSQL driver not loaded / QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7»Works for me on Windows with Qt SDK 5.6.0 (32bit version with mingw 4.9.2 32bit included) :
— Downloaded MySQL 32bit in zip archive (mine was v5.7.11)
— Extracted it to C:/MySQL
— Copied «C:\Qt\QMySQL\lib\libmysql.dll» and «C:\Qt\QMySQL\lib\libmysqld.dll» to Windows/System32 (to avoid the «cannot found -llibmysql» compilation error)
— Compile with «How to Build the QMYSQL Plugin on Windows» on http://doc.qt.io/qt-5/sql-driver.html#qmysql (my command was «qmake «INCLUDEPATH+=C:\Qt\QMySQL\include» «LIBS+=C:\Qt\QMySQL\lib\libmysql.lib» sql.pro» and «mingw32-make»)
— After compilation succeeded, copy (the freshly compiled) Qt5Sql.dll & Qt5Sqld.dll from «C:\Qt\Qt5.6.0\5.6\Src\qtbase\lib» to your application build directory
— Restart QtCreator, that should work
Similar Threads
-
Replies: 12
Last Post: 29th March 2017, 14:43
-
Replies: 7
Last Post: 15th November 2014, 07:29
-
Replies: 1
Last Post: 9th January 2011, 18:39
-
Replies: 3
Last Post: 1st June 2010, 13:09
-
Replies: 6
Last Post: 28th April 2009, 06:58
Bookmarks
Bookmarks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
- BB code is On
- Smilies are On
- [IMG] code is On
- [VIDEO] code is On
- HTML code is Off
Forum Rules
Qt is a trademark of The Qt Company.
-
Hi All,
I’m trying to make a program that inserts a record into a database. I can’t connect to the database. i get the following error:
QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
Steps I’ve taken:
install Qt,with the following options:
Installation directory: C:\Qt (default)
Components:
QT5.11.1-MinGW5.3.0 32 bit
Qt Creator 4.6.2 CBD Debugger Support (default)
Tools-MinGW5.3.0Install MySQL, with the following options:
mysql-installer-web-community-8.0.11.0.msi https://dev.mysql.com/downloads/file/?id=476476 Apply upgrade to the mysql installer: Yes [x]Accept License terms Setup type: Developer default (default) Connector/Python will not be installed Group replication: standalone (default) Type and networking: Config type: Development computer (all defaults) Authentication Method: Strong (default) MySQL root password: "PassOlyForForumQuestion" (no user accounts) Windows Server: (all defaults) MySql Router configuration: (all defaults) Connect to server: (all defaults)
Create a new Qt program, with the following options:
Qt widgets application
Name: sqlTest
Kit: Desktop Qt 5.11.1 MinGB 32 bit (default)
ClassName: (MainWindow) (default)
Version control: Gitmysql.pro
QT += core gui sql greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = sqlTest TEMPLATE = app DEFINES += QT_DEPRECATED_WARNINGS SOURCES += \ main.cpp \ mainwindow.cpp HEADERS += \ mainwindow.h FORMS += \ mainwindow.ui
mainwindow.cpp
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QtSql> #include <QDebug> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("localhost"); db.setDatabaseName("world"); db.setUserName("root"); db.setPassword("PassOlyForForumQuestion"); bool ok = db.open(); qDebug()<<ok; } MainWindow::~MainWindow() { delete ui; }
Program output:
QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7 false
My Versions:
MySQL 8.0.11
Qt 5.10.1
Windows 7 Professional SP1Whats going wrong?
Cheers,
Cedric -
Hi, I think you need to build your mysql driver to use it.
Here there is how could you build this driver
http://doc.qt.io/qt-5/sql-driver.htmlor Look this video:
https://www.youtube.com/watch?v=r1TbNjJSlX8[]s
-
Thanks Guapo,
I have watched the video, but I did not succeed yet.
I have run the maintenance tool, and added QT5.11.1-source.In the video, the file c:\qtSDK\4.8.1\src\plugins\sqldrivers\mysql\mysql.pro is used.
On my system it has moved to here: C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\mysql\mysql.pro
When I open the .pro file, I get the following messages:
Cannot read C:/Qt/5.11.1/Src/qtbase/src/plugins/sqldrivers/qtsqldrivers-config.pri: No such file or directory
Project ERROR: Project has no top-level .qmake.conf file.
Error while parsing file C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\mysql\mysql.pro. Giving up.
Cannot read C:/qtsqldrivers-config.pri: No such file or directory
Cannot read /mkspecs/modules-inst/qt_plugin_qsqlmysql.pri: No such file or directory
C:/Qt/5.11.1/mingw53_32/mkspecs/features/qt_plugin.prf(81): Variable QT_PLUGINS is not defined.
Project ERROR: Library ‘mysql’ is not defined.I don’t have the file qtsqldrivers-config.pri anywhere below c:\qt.
What can I do/check next?
Cheers,
Cedric -
Hi All,
I am trying to follow the instructions here, but I’m not successful yet. Configure reports MySql ……………………………. no
I have taken the following steps:
1)Add C:\Qt\Tools\mingw530_32\bin and C:\Qt\5.11.1\mingw53_32\bin to the path
2)Open cmd.exe, and enter the following commands:cd c:\qt\5.11.1\Src\qtbase\src\plugins\sqldrivers c:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="c:\Program Files\MySQL\Connector C++ 1.1\lib\opt" Running configuration tests... Checking for DB2 (IBM)... no Checking for InterBase... no Checking for MySQL... no Checking for OCI (Oracle)... no Checking for ODBC... yes Checking for PostgreSQL... no Checking for SQLite (version 2)... no Checking for TDS (Sybase)... no Done running configuration tests. Configure summary: Qt Sql: DB2 (IBM) .............................. no InterBase .............................. no MySql .................................. no OCI (Oracle) ........................... no ODBC ................................... yes PostgreSQL ............................. no SQLite2 ................................ no SQLite ................................. yes Using system provided SQLite ......... no TDS (Sybase) ........................... no Qt is now configured for building. Just run 'mingw32-make'. Once everything is built, Qt is installed. You should NOT run 'mingw32-make install'. Note that this build cannot be deployed to other machines or devices. Prior to reconfiguration, make sure you remove any leftovers from the previous build. c:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers>
What did I miss?
Cheers,
Cedric -
hi All,
I also have installed the «MySQL Connector C 6.1», but configure still does not see mySQL:
c:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="c:\Program Files\MySQL\MySQL Connector C 6.1\lib" Running configuration tests... Done running configuration tests. Configure summary: Qt Sql: DB2 (IBM) .............................. no InterBase .............................. no MySql .................................. no OCI (Oracle) ........................... no ODBC ................................... yes PostgreSQL ............................. no SQLite2 ................................ no SQLite ................................. yes Using system provided SQLite ......... no TDS (Sybase) ........................... no Qt is now configured for building. Just run 'mingw32-make'. Once everything is built, Qt is installed. You should NOT run 'mingw32-make install'. Note that this build cannot be deployed to other machines or devices. Prior to reconfiguration, make sure you remove any leftovers from the previous build. c:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="c:\Program Files\MySQL\MySQL Connector C 6.1\lib" Info: creating stash file C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\.qmake. stash Running configuration tests... Checking for DB2 (IBM)... no Checking for InterBase... no Checking for MySQL... no Checking for OCI (Oracle)... no Checking for ODBC... yes Checking for PostgreSQL... no Checking for SQLite (version 2)... no Checking for TDS (Sybase)... no Done running configuration tests. Configure summary: Qt Sql: DB2 (IBM) .............................. no InterBase .............................. no MySql .................................. no OCI (Oracle) ........................... no ODBC ................................... yes PostgreSQL ............................. no SQLite2 ................................ no SQLite ................................. yes Using system provided SQLite ......... no TDS (Sybase) ........................... no Qt is now configured for building. Just run 'mingw32-make'. Once everything is built, Qt is installed. You should NOT run 'mingw32-make install'. Note that this build cannot be deployed to other machines or devices. Prior to reconfiguration, make sure you remove any leftovers from the previous build. c:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers>
Cheers,
Cedric -
Lifetime Qt Champion
wrote on
last edited byHi,
Did you check that your MySQL Connector is built for 32bit ?
-
Hi Sgaist,
My further experiments:
I have downloaded the 32 bit C connector:https://downloads.mysql.com/archives/get/file/mysql-connector-c-6.1.11-win32.msi and installed it. Now I have this directory:
C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\lib
Due to the location it installed into, I’m confident that it’s indeed 32 bits. So here we go againI deleted all the generated files from C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers
C:\Users\cedric>cd c:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers c:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="c:\Program Files (x86)\MySQL\MySQL Connector C 6.1\lib" Running configuration tests... Checking for DB2 (IBM)... no Checking for InterBase... no Checking for MySQL... no Checking for OCI (Oracle)... no Checking for ODBC... yes Checking for PostgreSQL... no Checking for SQLite (version 2)... no Checking for TDS (Sybase)... no Done running configuration tests.
My config.log:
Command line: "MYSQL_INCDIR=c:\Program Files (x86)\MySQL\MySQL Connector C 6.1\lib" looking for library db2 Trying source 0 (type inline) of library db2 ... + cd /d C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\db2 && C:\Qt\5.11.1\mingw53_32\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresql\\pgsql\\lib" "INCLUDEPATH += C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresql\\pgsql\\include" "LIBS += -ldb2cli" C:/Qt/5.11.1/Src/qtbase/src/plugins/sqldrivers/config.tests/db2 + cd /d C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\db2 && set MAKEFLAGS=& mingw32-make clean && set MAKEFLAGS=& mingw32-make > del main.o > Could Not Find C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\db2\main.o > g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresql\pgsql\include -IC:\Qt\5.11.1\mingw53_32\mkspecs\win32-g++ -o main.o main.cpp > main.cpp:2:20: fatal error: sqlcli.h: No such file or directory > compilation terminated. > Makefile:415: recipe for target 'main.o' failed > mingw32-make: *** [main.o] Error 1 => source failed verification. Trying source 1 (type inline) of library db2 ... => source failed condition '!config.win32'. test config.sqldrivers.libraries.db2 FAILED looking for library ibase Trying source 0 (type inline) of library ibase ... + cd /d C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\ibase && C:\Qt\5.11.1\mingw53_32\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresql\\pgsql\\lib" "INCLUDEPATH += C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresql\\pgsql\\include" "LIBS += -lgds32_ms" C:/Qt/5.11.1/Src/qtbase/src/plugins/sqldrivers/config.tests/ibase + cd /d C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\ibase && set MAKEFLAGS=& mingw32-make clean && set MAKEFLAGS=& mingw32-make > del main.o > Could Not Find C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\ibase\main.o > g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresql\pgsql\include -IC:\Qt\5.11.1\mingw53_32\mkspecs\win32-g++ -o main.o main.cpp > main.cpp:2:19: fatal error: ibase.h: No such file or directory > compilation terminated. > Makefile:415: recipe for target 'main.o' failed > mingw32-make: *** [main.o] Error 1 => source failed verification. Trying source 1 (type inline) of library ibase ... => source failed condition '!config.win32'. test config.sqldrivers.libraries.ibase FAILED looking for library mysql Trying source 0 (type mysqlConfig) of library mysql ... mysql_config not found. => source produced no result. Trying source 1 (type mysqlConfig) of library mysql ... mysql_config not found. => source produced no result. Trying source 2 (type mysqlConfig) of library mysql ... mysql_config not found. => source produced no result. Trying source 3 (type mysqlConfig) of library mysql ... mysql_config not found. => source produced no result. Trying source 4 (type inline) of library mysql ... => source failed condition '!config.win32'. Trying source 5 (type inline) of library mysql ... + cd /d C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\mysql && C:\Qt\5.11.1\mingw53_32\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresql\\pgsql\\lib" "INCLUDEPATH += C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresql\\pgsql\\include" "LIBS += -llibmysql" "INCLUDEPATH *= \"c:\\Program Files ^(x86^)\\MySQL\\MySQL Connector C 6.1\\lib\"" C:/Qt/5.11.1/Src/qtbase/src/plugins/sqldrivers/config.tests/mysql + cd /d C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\mysql && set MAKEFLAGS=& mingw32-make clean && set MAKEFLAGS=& mingw32-make > del main.o > Could Not Find C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\mysql\main.o > g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresql\pgsql\include -I"c:\Program Files (x86)\MySQL\MySQL Connector C 6.1\lib" -IC:\Qt\5.11.1\mingw53_32\mkspecs\win32-g++ -o main.o main.cpp > main.cpp:5:19: fatal error: mysql.h: No such file or directory > compilation terminated. > Makefile:415: recipe for target 'main.o' failed > mingw32-make: *** [main.o] Error 1 => source failed verification. Trying source 6 (type inline) of library mysql ... => source failed condition '!config.win32'. test config.sqldrivers.libraries.mysql FAILED looking for library oci Trying source 0 (type inline) of library oci ... + cd /d C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\oci && C:\Qt\5.11.1\mingw53_32\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresql\\pgsql\\lib" "INCLUDEPATH += C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresql\\pgsql\\include" "LIBS += -loci" C:/Qt/5.11.1/Src/qtbase/src/plugins/sqldrivers/config.tests/oci + cd /d C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\oci && set MAKEFLAGS=& mingw32-make clean && set MAKEFLAGS=& mingw32-make > del main.o > Could Not Find C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\oci\main.o > g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresql\pgsql\include -IC:\Qt\5.11.1\mingw53_32\mkspecs\win32-g++ -o main.o main.cpp > main.cpp:2:17: fatal error: oci.h: No such file or directory > compilation terminated. > Makefile:415: recipe for target 'main.o' failed > mingw32-make: *** [main.o] Error 1 => source failed verification. Trying source 1 (type inline) of library oci ... => source failed condition '!config.win32'. test config.sqldrivers.libraries.oci FAILED looking for library odbc Trying source 0 (type inline) of library odbc ... + cd /d C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\odbc && C:\Qt\5.11.1\mingw53_32\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresql\\pgsql\\lib" "INCLUDEPATH += C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresql\\pgsql\\include" "LIBS += -lodbc32" C:/Qt/5.11.1/Src/qtbase/src/plugins/sqldrivers/config.tests/odbc + cd /d C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\odbc && set MAKEFLAGS=& mingw32-make clean && set MAKEFLAGS=& mingw32-make > del main.o > g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresql\pgsql\include -IC:\Qt\5.11.1\mingw53_32\mkspecs\win32-g++ -o main.o main.cpp > g++ -Wl,-s -Wl,-subsystem,console -mthreads -o odbc.exe main.o -LC:\openssl\lib -LC:\Utils\my_sql\mysql-5.6.11-win32\lib -LC:\Utils\postgresql\pgsql\lib -lodbc32 => source accepted. test config.sqldrivers.libraries.odbc succeeded looking for library psql Trying source 0 (type pkgConfig) of library psql ... pkg-config use disabled globally. => source produced no result. Trying source 1 (type psqlConfig) of library psql ... pg_config not found. => source produced no result. Trying source 2 (type psqlEnv) of library psql ... + cd /d C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\psql && C:\Qt\5.11.1\mingw53_32\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresql\\pgsql\\lib" "INCLUDEPATH += C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresql\\pgsql\\include" "LIBS += -llibpq -lws2_32 -ladvapi32" C:/Qt/5.11.1/Src/qtbase/src/plugins/sqldrivers/config.tests/psql + cd /d C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\psql && set MAKEFLAGS=& mingw32-make clean && set MAKEFLAGS=& mingw32-make > del main.o > Could Not Find C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\psql\main.o > g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresql\pgsql\include -IC:\Qt\5.11.1\mingw53_32\mkspecs\win32-g++ -o main.o main.cpp > main.cpp:2:22: fatal error: libpq-fe.h: No such file or directory > compilation terminated. > Makefile:415: recipe for target 'main.o' failed > mingw32-make: *** [main.o] Error 1 => source failed verification. Trying source 3 (type psqlEnv) of library psql ... => source failed condition '!config.win32'. test config.sqldrivers.libraries.psql FAILED looking for library sqlite2 Trying source 0 (type inline) of library sqlite2 ... + cd /d C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\sqlite2 && C:\Qt\5.11.1\mingw53_32\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresql\\pgsql\\lib" "INCLUDEPATH += C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresql\\pgsql\\include" "LIBS += -lsqlite" C:/Qt/5.11.1/Src/qtbase/src/plugins/sqldrivers/config.tests/sqlite2 + cd /d C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\sqlite2 && set MAKEFLAGS=& mingw32-make clean && set MAKEFLAGS=& mingw32-make > del main.o > Could Not Find C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\sqlite2\main.o > g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresql\pgsql\include -IC:\Qt\5.11.1\mingw53_32\mkspecs\win32-g++ -o main.o main.cpp > main.cpp:2:20: fatal error: sqlite.h: No such file or directory > compilation terminated. > Makefile:415: recipe for target 'main.o' failed > mingw32-make: *** [main.o] Error 1 => source failed verification. test config.sqldrivers.libraries.sqlite2 FAILED looking for library tds Trying source 0 (type sybaseEnv) of library tds ... + cd /d C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\tds && C:\Qt\5.11.1\mingw53_32\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib C:\\Utils\\postgresql\\pgsql\\lib" "INCLUDEPATH += C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.6.11-win32\\include C:\\Utils\\postgresql\\pgsql\\include" "LIBS += -lNTWDBLIB" C:/Qt/5.11.1/Src/qtbase/src/plugins/sqldrivers/config.tests/tds + cd /d C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\tds && set MAKEFLAGS=& mingw32-make clean && set MAKEFLAGS=& mingw32-make > del main.o > Could Not Find C:\Qt\5.11.1\Src\qtbase\src\plugins\sqldrivers\config.tests\tds\main.o > g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.6.11-win32\include -IC:\Utils\postgresql\pgsql\include -IC:\Qt\5.11.1\mingw53_32\mkspecs\win32-g++ -o main.o main.cpp > main.cpp:2:22: fatal error: sybfront.h: No such file or directory > compilation terminated. > Makefile:415: recipe for target 'main.o' failed > mingw32-make: *** [main.o] Error 1 => source failed verification. Trying source 1 (type sybaseEnv) of library tds ... => source failed condition '!config.win32'. test config.sqldrivers.libraries.tds FAILED
my config.cache:
cache.platform = win32-g++ cache.xplatform = win32-g++ cache.db2._KEYS_ = result msgs cache.db2.result = false cache.db2.msgs = "Trying source 0 (type inline) of library db2 ..." "+ cd /d C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\db2 && C:\\Qt\\5.11.1\\mingw53_32\\bin\\qmake.exe \"CONFIG -= qt debug_and_release app_bundle lib_bundle\" \"CONFIG += shared warn_off console single_arch\" \"QMAKE_LIBDIR += C:\\\\openssl\\\\lib C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\lib C:\\\\Utils\\\\postgresql\\\\pgsql\\\\lib\" \"INCLUDEPATH += C:\\\\openssl\\\\include C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\include C:\\\\Utils\\\\postgresql\\\\pgsql\\\\include\" \"LIBS += -ldb2cli\" C:/Qt/5.11.1/Src/qtbase/src/plugins/sqldrivers/config.tests/db2" "+ cd /d C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\db2 && set MAKEFLAGS=& mingw32-make clean && set MAKEFLAGS=& mingw32-make" "> del main.o" "> Could Not Find C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\db2\\main.o" "> g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\\openssl\\include -IC:\\Utils\\my_sql\\mysql-5.6.11-win32\\include -IC:\\Utils\\postgresql\\pgsql\\include -IC:\\Qt\\5.11.1\\mingw53_32\\mkspecs\\win32-g++ -o main.o main.cpp" "> main.cpp:2:20: fatal error: sqlcli.h: No such file or directory" "> compilation terminated." "> Makefile:415: recipe for target \'main.o\' failed" "> mingw32-make: *** [main.o] Error 1" " => source failed verification." "Trying source 1 (type inline) of library db2 ..." " => source failed condition \'!config.win32\'." cache.ibase._KEYS_ = result msgs cache.ibase.result = false cache.ibase.msgs = "Trying source 0 (type inline) of library ibase ..." "+ cd /d C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\ibase && C:\\Qt\\5.11.1\\mingw53_32\\bin\\qmake.exe \"CONFIG -= qt debug_and_release app_bundle lib_bundle\" \"CONFIG += shared warn_off console single_arch\" \"QMAKE_LIBDIR += C:\\\\openssl\\\\lib C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\lib C:\\\\Utils\\\\postgresql\\\\pgsql\\\\lib\" \"INCLUDEPATH += C:\\\\openssl\\\\include C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\include C:\\\\Utils\\\\postgresql\\\\pgsql\\\\include\" \"LIBS += -lgds32_ms\" C:/Qt/5.11.1/Src/qtbase/src/plugins/sqldrivers/config.tests/ibase" "+ cd /d C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\ibase && set MAKEFLAGS=& mingw32-make clean && set MAKEFLAGS=& mingw32-make" "> del main.o" "> Could Not Find C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\ibase\\main.o" "> g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\\openssl\\include -IC:\\Utils\\my_sql\\mysql-5.6.11-win32\\include -IC:\\Utils\\postgresql\\pgsql\\include -IC:\\Qt\\5.11.1\\mingw53_32\\mkspecs\\win32-g++ -o main.o main.cpp" "> main.cpp:2:19: fatal error: ibase.h: No such file or directory" "> compilation terminated." "> Makefile:415: recipe for target \'main.o\' failed" "> mingw32-make: *** [main.o] Error 1" " => source failed verification." "Trying source 1 (type inline) of library ibase ..." " => source failed condition \'!config.win32\'." cache.mysql._KEYS_ = result msgs cache.mysql.result = false cache.mysql.msgs = "Trying source 0 (type mysqlConfig) of library mysql ..." "mysql_config not found." " => source produced no result." "Trying source 1 (type mysqlConfig) of library mysql ..." "mysql_config not found." " => source produced no result." "Trying source 2 (type mysqlConfig) of library mysql ..." "mysql_config not found." " => source produced no result." "Trying source 3 (type mysqlConfig) of library mysql ..." "mysql_config not found." " => source produced no result." "Trying source 4 (type inline) of library mysql ..." " => source failed condition \'!config.win32\'." "Trying source 5 (type inline) of library mysql ..." "+ cd /d C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\mysql && C:\\Qt\\5.11.1\\mingw53_32\\bin\\qmake.exe \"CONFIG -= qt debug_and_release app_bundle lib_bundle\" \"CONFIG += shared warn_off console single_arch\" \"QMAKE_LIBDIR += C:\\\\openssl\\\\lib C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\lib C:\\\\Utils\\\\postgresql\\\\pgsql\\\\lib\" \"INCLUDEPATH += C:\\\\openssl\\\\include C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\include C:\\\\Utils\\\\postgresql\\\\pgsql\\\\include\" \"LIBS += -llibmysql\" \"INCLUDEPATH *= \\\"c:\\\\Program Files ^(x86^)\\\\MySQL\\\\MySQL Connector C 6.1\\\\lib\\\"\" C:/Qt/5.11.1/Src/qtbase/src/plugins/sqldrivers/config.tests/mysql" "+ cd /d C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\mysql && set MAKEFLAGS=& mingw32-make clean && set MAKEFLAGS=& mingw32-make" "> del main.o" "> Could Not Find C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\mysql\\main.o" "> g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\\openssl\\include -IC:\\Utils\\my_sql\\mysql-5.6.11-win32\\include -IC:\\Utils\\postgresql\\pgsql\\include -I\"c:\\Program Files (x86)\\MySQL\\MySQL Connector C 6.1\\lib\" -IC:\\Qt\\5.11.1\\mingw53_32\\mkspecs\\win32-g++ -o main.o main.cpp" "> main.cpp:5:19: fatal error: mysql.h: No such file or directory" "> compilation terminated." "> Makefile:415: recipe for target \'main.o\' failed" "> mingw32-make: *** [main.o] Error 1" " => source failed verification." "Trying source 6 (type inline) of library mysql ..." " => source failed condition \'!config.win32\'." cache.oci._KEYS_ = result msgs cache.oci.result = false cache.oci.msgs = "Trying source 0 (type inline) of library oci ..." "+ cd /d C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\oci && C:\\Qt\\5.11.1\\mingw53_32\\bin\\qmake.exe \"CONFIG -= qt debug_and_release app_bundle lib_bundle\" \"CONFIG += shared warn_off console single_arch\" \"QMAKE_LIBDIR += C:\\\\openssl\\\\lib C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\lib C:\\\\Utils\\\\postgresql\\\\pgsql\\\\lib\" \"INCLUDEPATH += C:\\\\openssl\\\\include C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\include C:\\\\Utils\\\\postgresql\\\\pgsql\\\\include\" \"LIBS += -loci\" C:/Qt/5.11.1/Src/qtbase/src/plugins/sqldrivers/config.tests/oci" "+ cd /d C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\oci && set MAKEFLAGS=& mingw32-make clean && set MAKEFLAGS=& mingw32-make" "> del main.o" "> Could Not Find C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\oci\\main.o" "> g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\\openssl\\include -IC:\\Utils\\my_sql\\mysql-5.6.11-win32\\include -IC:\\Utils\\postgresql\\pgsql\\include -IC:\\Qt\\5.11.1\\mingw53_32\\mkspecs\\win32-g++ -o main.o main.cpp" "> main.cpp:2:17: fatal error: oci.h: No such file or directory" "> compilation terminated." "> Makefile:415: recipe for target \'main.o\' failed" "> mingw32-make: *** [main.o] Error 1" " => source failed verification." "Trying source 1 (type inline) of library oci ..." " => source failed condition \'!config.win32\'." cache.odbc._KEYS_ = result msgs source sources.0.libs sources.0.includedir sources.0.cflags sources.0.version sources.0.export cache.odbc.result = true cache.odbc.msgs = "Trying source 0 (type inline) of library odbc ..." "+ cd /d C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\odbc && C:\\Qt\\5.11.1\\mingw53_32\\bin\\qmake.exe \"CONFIG -= qt debug_and_release app_bundle lib_bundle\" \"CONFIG += shared warn_off console single_arch\" \"QMAKE_LIBDIR += C:\\\\openssl\\\\lib C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\lib C:\\\\Utils\\\\postgresql\\\\pgsql\\\\lib\" \"INCLUDEPATH += C:\\\\openssl\\\\include C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\include C:\\\\Utils\\\\postgresql\\\\pgsql\\\\include\" \"LIBS += -lodbc32\" C:/Qt/5.11.1/Src/qtbase/src/plugins/sqldrivers/config.tests/odbc" "+ cd /d C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\odbc && set MAKEFLAGS=& mingw32-make clean && set MAKEFLAGS=& mingw32-make" "> del main.o" "> g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\\openssl\\include -IC:\\Utils\\my_sql\\mysql-5.6.11-win32\\include -IC:\\Utils\\postgresql\\pgsql\\include -IC:\\Qt\\5.11.1\\mingw53_32\\mkspecs\\win32-g++ -o main.o main.cpp" "> g++ -Wl,-s -Wl,-subsystem,console -mthreads -o odbc.exe main.o -LC:\\openssl\\lib -LC:\\Utils\\my_sql\\mysql-5.6.11-win32\\lib -LC:\\Utils\\postgresql\\pgsql\\lib -lodbc32 " " => source accepted." cache.odbc.source = 0 cache.odbc.sources.0.libs = -lodbc32 cache.odbc.sources.0.includedir = cache.odbc.sources.0.cflags = cache.odbc.sources.0.version = cache.odbc.sources.0.export = cache.psql._KEYS_ = result msgs cache.psql.result = false cache.psql.msgs = "Trying source 0 (type pkgConfig) of library psql ..." "pkg-config use disabled globally." " => source produced no result." "Trying source 1 (type psqlConfig) of library psql ..." "pg_config not found." " => source produced no result." "Trying source 2 (type psqlEnv) of library psql ..." "+ cd /d C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\psql && C:\\Qt\\5.11.1\\mingw53_32\\bin\\qmake.exe \"CONFIG -= qt debug_and_release app_bundle lib_bundle\" \"CONFIG += shared warn_off console single_arch\" \"QMAKE_LIBDIR += C:\\\\openssl\\\\lib C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\lib C:\\\\Utils\\\\postgresql\\\\pgsql\\\\lib\" \"INCLUDEPATH += C:\\\\openssl\\\\include C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\include C:\\\\Utils\\\\postgresql\\\\pgsql\\\\include\" \"LIBS += -llibpq -lws2_32 -ladvapi32\" C:/Qt/5.11.1/Src/qtbase/src/plugins/sqldrivers/config.tests/psql" "+ cd /d C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\psql && set MAKEFLAGS=& mingw32-make clean && set MAKEFLAGS=& mingw32-make" "> del main.o" "> Could Not Find C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\psql\\main.o" "> g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\\openssl\\include -IC:\\Utils\\my_sql\\mysql-5.6.11-win32\\include -IC:\\Utils\\postgresql\\pgsql\\include -IC:\\Qt\\5.11.1\\mingw53_32\\mkspecs\\win32-g++ -o main.o main.cpp" "> main.cpp:2:22: fatal error: libpq-fe.h: No such file or directory" "> compilation terminated." "> Makefile:415: recipe for target \'main.o\' failed" "> mingw32-make: *** [main.o] Error 1" " => source failed verification." "Trying source 3 (type psqlEnv) of library psql ..." " => source failed condition \'!config.win32\'." cache.sqlite2._KEYS_ = result msgs cache.sqlite2.result = false cache.sqlite2.msgs = "Trying source 0 (type inline) of library sqlite2 ..." "+ cd /d C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\sqlite2 && C:\\Qt\\5.11.1\\mingw53_32\\bin\\qmake.exe \"CONFIG -= qt debug_and_release app_bundle lib_bundle\" \"CONFIG += shared warn_off console single_arch\" \"QMAKE_LIBDIR += C:\\\\openssl\\\\lib C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\lib C:\\\\Utils\\\\postgresql\\\\pgsql\\\\lib\" \"INCLUDEPATH += C:\\\\openssl\\\\include C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\include C:\\\\Utils\\\\postgresql\\\\pgsql\\\\include\" \"LIBS += -lsqlite\" C:/Qt/5.11.1/Src/qtbase/src/plugins/sqldrivers/config.tests/sqlite2" "+ cd /d C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\sqlite2 && set MAKEFLAGS=& mingw32-make clean && set MAKEFLAGS=& mingw32-make" "> del main.o" "> Could Not Find C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\sqlite2\\main.o" "> g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\\openssl\\include -IC:\\Utils\\my_sql\\mysql-5.6.11-win32\\include -IC:\\Utils\\postgresql\\pgsql\\include -IC:\\Qt\\5.11.1\\mingw53_32\\mkspecs\\win32-g++ -o main.o main.cpp" "> main.cpp:2:20: fatal error: sqlite.h: No such file or directory" "> compilation terminated." "> Makefile:415: recipe for target \'main.o\' failed" "> mingw32-make: *** [main.o] Error 1" " => source failed verification." cache.tds._KEYS_ = result msgs cache.tds.result = false cache.tds.msgs = "Trying source 0 (type sybaseEnv) of library tds ..." "+ cd /d C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\tds && C:\\Qt\\5.11.1\\mingw53_32\\bin\\qmake.exe \"CONFIG -= qt debug_and_release app_bundle lib_bundle\" \"CONFIG += shared warn_off console single_arch\" \"QMAKE_LIBDIR += C:\\\\openssl\\\\lib C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\lib C:\\\\Utils\\\\postgresql\\\\pgsql\\\\lib\" \"INCLUDEPATH += C:\\\\openssl\\\\include C:\\\\Utils\\\\my_sql\\\\mysql-5.6.11-win32\\\\include C:\\\\Utils\\\\postgresql\\\\pgsql\\\\include\" \"LIBS += -lNTWDBLIB\" C:/Qt/5.11.1/Src/qtbase/src/plugins/sqldrivers/config.tests/tds" "+ cd /d C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\tds && set MAKEFLAGS=& mingw32-make clean && set MAKEFLAGS=& mingw32-make" "> del main.o" "> Could Not Find C:\\Qt\\5.11.1\\Src\\qtbase\\src\\plugins\\sqldrivers\\config.tests\\tds\\main.o" "> g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -I. -IC:\\openssl\\include -IC:\\Utils\\my_sql\\mysql-5.6.11-win32\\include -IC:\\Utils\\postgresql\\pgsql\\include -IC:\\Qt\\5.11.1\\mingw53_32\\mkspecs\\win32-g++ -o main.o main.cpp" "> main.cpp:2:22: fatal error: sybfront.h: No such file or directory" "> compilation terminated." "> Makefile:415: recipe for target \'main.o\' failed" "> mingw32-make: *** [main.o] Error 1" " => source failed verification." "Trying source 1 (type sybaseEnv) of library tds ..." " => source failed condition \'!config.win32\'."
qtsqldrivers-config.pri
QT.sqldrivers.enabled_features = QT.sqldrivers.disabled_features = QT.sqldrivers.QT_CONFIG = QT.sqldrivers.exports = QT.sqldrivers_private.enabled_features = sql-odbc sql-sqlite QT.sqldrivers_private.disabled_features = sql-db2 sql-ibase sql-mysql sql-oci sql-psql sql-sqlite2 sql-tds system-sqlite QT.sqldrivers_private.libraries = odbc QMAKE_LIBS_ODBC = -lodbc32
Cheers,
Cedric -
Lifetime Qt Champion
wrote on
last edited byWhere exactly do you have
mysql.h
located on your computer ? -
Hi, i have mysql.h at the following locations:
C:\Program Files\MySQL\MySQL Server 8.0\include
C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include
C:\Program Files\MySQL\MySQL Connector C 6.1\includeCheers,
Cedric -
Lifetime Qt Champion
wrote on
last edited by SGaistThen why are you using
MYSQL_INCDIR="c:\Program Files (x86)\MySQL\MySQL Connector C 6.1\lib"
?
It should beinclude
and notlib
. -
Thank you.
I used /lib because it’s in on the instructions on the Qt website: http://doc.qt.io/qt-5/sql-driver.html Can I file a bug report for the instructions on the site?How to Build the QMYSQL Plugin on Windows You need to get the MySQL installation files. Run SETUP.EXE and choose "Custom Install". Install the "Libs & Include Files" Module. Build the plugin as follows (here it is assumed that MySQL is installed in C:\MySQL): cd %QTDIR%\qtbase\src\plugins\sqldrivers qmake -- MYSQL_INCDIR=C:/MySQL/include "MYSQL_LIBDIR=C:/MYSQL/MySQL Server <version>/lib/opt" nmake sub-mysql If you are not using a Microsoft compiler, replace nmake with mingw32-make in the line above.
I’ll test your suggestion shortly.
Cheers,
Cedric -
Lifetime Qt Champion
wrote on
last edited byI think you may have misread the documentation.
There are two variables:
MYSQL_INCDIR
andMYSQL_LIBDIR
. -
I see it now, I indeed only typed halve of the command.
Thanks, I can now test it further.Cheers,
Cedric -
wrote on
last edited by Cobra91151Hello! Do you have
libs
included in your.pro
file?contains(QMAKE_TARGET.arch, x86_64) { LIBS += -L"C:/MySQL/mysql-5.7.22-winx64/lib" -llibmysql } else { LIBS += -L"C:/MySQL/mysql-5.7.22-win32/lib" -llibmysql }
Note that you need to download the
MySQL
from here MySQL Community Server and extract the data for example toC
drive. Also I suggest to copylibmysql.dll
to the application directory.I use
Qt 5.9.6
andVisual Studio 2017
compiler and it doesn’t require to build the driver forMySQL
. -
Hi All,
I’m one step closer to my goal, I can now build the plugin. I cannot yet connect to my database.
Steps I’ve taken:- Download and install https://downloads.mysql.com/archives/get/file/mysql-connector-c-6.1.11-win32.msi
- Add C:\Qt\Tools\mingw530_32\bin and C:\Qt\5.10.1\mingw53_32\bin to the path
- Open cmd.exe, and enter the following commands:
c:\Qt\5.10.1\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="c:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" MYSQL_LIBDIR="c:\Program Files (x86)\MySQL\MySQL Connector C 6.1"\lib Running configuration tests... Checking for DB2 (IBM)... no Checking for InterBase... no Checking for MySQL... yes Checking for OCI (Oracle)... no Checking for ODBC... yes Checking for PostgreSQL... no Checking for SQLite (version 2)... no Checking for TDS (Sybase)... no Done running configuration tests. Configure summary: Qt Sql: DB2 (IBM) .............................. no InterBase .............................. no MySql .................................. yes OCI (Oracle) ........................... no ODBC ................................... yes PostgreSQL ............................. no SQLite2 ................................ no SQLite ................................. yes Using system provided SQLite ......... no TDS (Sybase) ........................... no Qt is now configured for building. Just run 'mingw32-make'. Once everything is built, Qt is installed. You should NOT run 'mingw32-make install'. Note that this build cannot be deployed to other machines or devices. Prior to reconfiguration, make sure you remove any leftovers from the previous build. mingw32-make <<lots of text>>
- Create a new Qt program, with the following options:
Qt widgets application
Name: sqlTest
Kit: Desktop Qt 5.11.1 MinGB 32 bit (default)
ClassName: (MainWindow) (default)
Version control: Git
mysql.pro
QT += core gui sql greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = sqlTest TEMPLATE = app DEFINES += QT_DEPRECATED_WARNINGS SOURCES += \ main.cpp \ mainwindow.cpp HEADERS += \ mainwindow.h FORMS += \ mainwindow.ui
mainwindow.cpp
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QtSql> #include <QDebug> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("localhost"); db.setDatabaseName("world"); db.setUserName("root"); db.setPassword("PassOlyForForumQuestion"); bool ok = db.open(); qDebug()<<ok; } MainWindow::~MainWindow() { delete ui; }
Program output:
QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7 false
Cheers,
Cedric -
Lifetime Qt Champion
wrote on
last edited byDid you install the plugin ?
Did you also check that the
PATH
environment variable in the Run part of the Project panel contains the folder where the MySQL .dlls can be found ? -
Did you install the plugin ?
Did you also check that the
PATH
environment variable in the Run part of the Project panel contains the folder where the MySQL .dlls can be found ?wrote on
last edited by cdwijsHow can I install the plugin? Where can the plugin be found? What does it look like? Where does Qt look for the plugin?
Why does the Qt runtime tell me the QMYSQL driver is available while the driver cannot be loaded? Is there any way to see why the driver did not load?
Is there a guide anywhere that works with the current version of myqsl and the current version of Qt? This guide is for mysql version 5.1: https://forum.qt.io/topic/40672/how-to-create-the-plugin-of-mysql-for-qt
Am I the first one that tries to use Qt 5 and mysql server 8?
Cheers,
Cedric -
Lifetime Qt Champion
wrote on
last edited byIt’s explained in the documentation
In the plugins subfolder of your Qt installation undersqldrivers
.
It’s a .dll file since you’re on Windows.
Qt looks for the plugins in the subfolder named plugins unless you tweaked the qt.conf file.Likely because it can find the plugin but will fail to load it. Most of the time it happens because the MySQL .dll files can’t be found at run time hence my suggestion in my last post.
The current Qt documentation does.
No you’re note, however MySQL server 8 saw a change in their support for their
my_bool
custom type. There’s a patch to support build the Qt MySQL plugin with MySQL 8. -
Thanks for your reply.
The documentation you linked (http://doc.qt.io/qt-5/sql-driver.html#building-the-drivers) assumes mysql is installed in c:\mysql. This is not the case for a default installation of mysql8, as it installs itself into c:\program files and c:\program files (x86). This leads me to the conclusion that the install instructions on that page are outdated.
Do you know any instructions for building the plugin for qt5 and mysql 8?
Cheers,
Cedric -
Lifetime Qt Champion
wrote on
last edited byThe doc says:
You need to get the MySQL installation files. Run SETUP.EXE and choose "Custom Install". Install the "Libs & Include Files" Module. Build the plugin as follows (here it is assumed that MySQL is installed in C:\MySQL):
This simply means that it assumes that the user selected that folder to install MySQL.
Then:
cd %QTDIR%\qtbase\src\plugins\sqldrivers qmake -- MYSQL_INCDIR=C:/MySQL/include "MYSQL_LIBDIR=C:/MYSQL/MySQL Server <version>/lib/opt" nmake sub-mysql
It shows that the build is configured to use that folder.
If you put MySQL somewhere else, update the command accordingly to use that folder.