QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7 I need QMYSQL
-
hi there,
i need help i just cant figure it out.
i almost tried everything out here is my code:
#include "login.h"
#include "ui_login.h"Login::Login(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::Login)
{ui->setupUi(this); QGraphicsScene scene; QPixmap pixmap(":/logo.jpg"); scene.addPixmap(pixmap); ui->graphicsView->setScene(&scene); QSqlDatabase Logindb=QSqlDatabase::addDatabase("QMYSQL"); Logindb.setHostName("127.0.0.1"); Logindb.setPort(3306); Logindb.setDatabaseName("agr_kako"); Logindb.setUserName("root"); Logindb.setPassword("1234"); Logindb.open(); if(!Logindb.open()) {ui->label_3->setText("Failed to open the database");} else ui->label_3->setText("Connected");
}
Login::~Login()
{
delete ui;
}void Login::on_pushButton_signin_clicked()
{Logindb.open(); QString username,passwort; username=ui->lineEdit_User->text(); passwort=ui->lineEdit_Password->text();
// QSqlQuery qry;
// if(qry.exec("select * from login where Nachname='"+username+"'and Passwort'"+passwort+"'"))
// {
// int count=0;
// while(qry.next())
// {
// count++;
// }
// if(count==1)
// ui->label_3->setText("Login erfolgreich");
// if(count>1)
// ui->label_3->setText("");
// if(count==1)
// ui->label_3->setText("Login fehlgeschlagen Passwort oder Name falsch");
// }
// if(!Logindb.isOpen())
// {
// qDebug()<<"Verbindung zur Datenbank verloren";
// return;
// }parameter=new Parameter(this); parameter->show(); hide();
}
and here is my output:
10:48:54: Starte E:\qtprojekts\build-AGR-KAKO-Desktop_Qt_5_15_0_MinGW_64_bit-Debug\debug\sqlTest.exe ...
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7my database is a localhost mariadb wich is called agr_kako and the table is called login and has 2 names in it.
-
@JonnyQB What did you try? Most probably you do not have MySQL client libs.
Set QT_DEBUG_PLUGINS (https://doc.qt.io/qt-5/deployment-plugins.html) before starting your app, then start your app and check the output. -
E:\Programme\qt\Tools\5.15.0\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="C:/Program Files/MySQL/MySQL Connector C++ 8.0/include" MYSQL_LIBDIR="C:/Program Files/MySQL/MySQL Connector C++ 8.0//lib"
Running configuration tests...
Done running configuration tests.Configure summary:
Qt Sql Drivers:
DB2 (IBM) .............................. no
InterBase .............................. no
MySql .................................. no
OCI (Oracle) ........................... no
ODBC ................................... no
PostgreSQL ............................. no
SQLite2 ................................ no
SQLite ................................. yes
Using system provided SQLite ......... no
TDS (Sybase) ........................... noQt is now configured for building. Just run 'mingw32-make'.
Once everything is built, you must run 'mingw32-make install'.
Qt will be installed into 'E:\Programme\qt\Tools\5.15.0\mingw81_64'.Prior to reconfiguration, make sure you remove any leftovers from
the previous build.
i tried building but now i got this.... -
@JonnyQB said in QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7 I need QMYSQL:
wich config.log do you mean and where could i find it
In the build folder (from where you called qmake)
-
@jsulm
i got this
Trying source 1 (type inline) of library odbc ...
=> source failed condition 'config.darwin'.
Trying source 2 (type inline) of library odbc ...
=> source failed condition '!config.win32 && !config.darwin'.
test config.sqldrivers.libraries.odbc FAILED
loaded result for library config.sqldrivers.libraries.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 ...
libpq-fe.h not found in [] and global paths.
=> source produced no result.
Trying source 3 (type psqlEnv) of library psql ...
=> source failed condition '!config.win32'.
test config.sqldrivers.libraries.psql FAILED
loaded result for library config.sqldrivers.libraries.sqlite2
Trying source 0 (type inline) of library sqlite2 ...
sqlite.h not found in [] and global paths.
=> source produced no result.
test config.sqldrivers.libraries.sqlite2 FAILED
loaded result for library config.sqldrivers.libraries.tds
Trying source 0 (type sybaseEnv) of library tds ...- cd /d E:\Programme\qt\Tools\5.15.0\Src\qtbase\src\plugins\sqldrivers\config.tests\tds && E:\Programme\qt\Tools\5.15.0\mingw81_64\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.7.25-winx64\lib C:\Utils\postgresql\pgsql\lib" "INCLUDEPATH += C:\openssl\include C:\Utils\my_sql\mysql-5.7.25-winx64\include C:\Utils\postgresql\pgsql\include" "QMAKE_USE += tds" "QMAKE_LIBS_TDS = -lNTWDBLIB" E:/Programme/qt/Tools/5.15.0/Src/qtbase/src/plugins/sqldrivers/config.tests/tds
Project ERROR: Cannot run compiler 'g++'. Output:
===================
===================
Maybe you forgot to setup the environment?
=> source failed verification.
Trying source 1 (type sybaseEnv) of library tds ...
=> source failed condition '!config.win32'.
test config.sqldrivers.libraries.tds FAILED
what should i do
- cd /d E:\Programme\qt\Tools\5.15.0\Src\qtbase\src\plugins\sqldrivers\config.tests\tds && E:\Programme\qt\Tools\5.15.0\mingw81_64\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.7.25-winx64\lib C:\Utils\postgresql\pgsql\lib" "INCLUDEPATH += C:\openssl\include C:\Utils\my_sql\mysql-5.7.25-winx64\include C:\Utils\postgresql\pgsql\include" "QMAKE_USE += tds" "QMAKE_LIBS_TDS = -lNTWDBLIB" E:/Programme/qt/Tools/5.15.0/Src/qtbase/src/plugins/sqldrivers/config.tests/tds
-
@JonnyQB said in QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7 I need QMYSQL:
what should i do
make sure you open the correct Qt command prompt where a g++ compiler is available.
-
@JonnyQB you could use my precompiled QMYSQL driver from https://github.com/thecodemonkey86/qt_mysql_driver if you like. I tested it with MariaDB as well
-
@Christian-Ehrlicher
i set the path to both files like in the doc from qt. -
@Christian-Ehrlicher
E:\Programme\qt\Tools\5.15.0\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="C:/Program Files/MySQL/MySQL Connector C++ 8.0/include" MYSQL_LIBDIR="C:/Program Files/MySQL/MySQL Connector C++ 8.0//lib"Running configuration tests...
Done running configuration tests.Configure summary:
Qt Sql Drivers:
DB2 (IBM) .............................. no
InterBase .............................. no
MySql .................................. no
OCI (Oracle) ........................... no
ODBC ................................... no
PostgreSQL ............................. no
SQLite2 ................................ no
SQLite ................................. yes
Using system provided SQLite ......... no
TDS (Sybase) ........................... noQt is now configured for building. Just run 'mingw32-make'.
Once everything is built, you must run 'mingw32-make install'.
Qt will be installed into 'E:\Programme\qt\Tools\5.15.0\mingw81_64'.Prior to reconfiguration, make sure you remove any leftovers from
the previous build.E:\Programme\qt\Tools\5.15.0\Src\qtbase\src\plugins\sqldrivers>where g++
E:\Programme\qt\Tools\mingw810_64\bin\g++.exeE:\Programme\qt\Tools\5.15.0\Src\qtbase\src\plugins\sqldrivers>where gcc
E:\Programme\qt\Tools\mingw810_64\bin\gcc.exe -
Hi, just to check, remember to remove the config.cache file before you run configure. This is easy to forget (I did :-) here's an answer from a previous, similar discussion:
@Bonnie said in Set-up MariaDB library file location programmatically?:
@SPlatten
It is actually in the doc:If something goes wrong and you want qmake to recheck your available drivers, you must remove config.cache in <QTDIR>/qtbase/src/plugins/sqldrivers - otherwise qmake will not search for the available drivers again.
I think the doc should make that sentence more sight-catching.
Many people who had their first qmake command unsuccessful would be stucked there, with a never-changing config.log. -
@hskoglund next release of the documentation shall have that modification :-)
-
E:\Programme\qt\Tools\5.15.0\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="C:/Program Files/MySQL/MySQL Connector C++ 8.0/include" MYSQL_LIBDIR="C:/Program Files/MySQL/MySQL Connector C++ 8.0//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.Configure summary:
Qt Sql Drivers:
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) ........................... noQt is now configured for building. Just run 'mingw32-make'.
Once everything is built, you must run 'mingw32-make install'.
Qt will be installed into 'E:\Programme\qt\Tools\5.15.0\mingw81_64'.Prior to reconfiguration, make sure you remove any leftovers from
the previous build.but i still get this
and i need mysql .... -
@jsulm
Command line: "MYSQL_INCDIR=C:/Program Files/MySQL/MySQL Connector C++ 8.0/include" "MYSQL_LIBDIR=C:/Program Files/MySQL/MySQL Connector C++ 8.0//lib"
Global lib dirs: [C:\openssl\lib C:\Utils\my_sql\mysql-5.7.25-winx64\lib C:\Utils\postgresql\pgsql\lib] [E:/Programme/qt/Tools/Tools/mingw810_64/lib/gcc/x86_64-w64-mingw32/8.1.0 E:/Programme/qt/Tools/Tools/mingw810_64/lib/gcc E:/Programme/qt/Tools/Tools/mingw810_64/x86_64-w64-mingw32/lib E:/Programme/qt/Tools/Tools/mingw810_64/lib]
Global inc dirs: [C:\openssl\include C:\Utils\my_sql\mysql-5.7.25-winx64\include C:\Utils\postgresql\pgsql\include] [E:/Programme/qt/Tools/Tools/mingw810_64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++ E:/Programme/qt/Tools/Tools/mingw810_64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32 E:/Programme/qt/Tools/Tools/mingw810_64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward E:/Programme/qt/Tools/Tools/mingw810_64/lib/gcc/x86_64-w64-mingw32/8.1.0/include E:/Programme/qt/Tools/Tools/mingw810_64/lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed E:/Programme/qt/Tools/Tools/mingw810_64/x86_64-w64-mingw32/include]
looking for library db2
Trying source 0 (type inline) of library db2 ...
sqlcli.h not found in [] and global paths.
sqlcli1.h not found in [] and global paths.
=> source produced no result.
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 ...
ibase.h not found in [] and global paths.
=> source produced no result.
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 ...
mysql.h not found in ["C:/Program Files/MySQL/MySQL Connector C++ 8.0/include"] and global paths.
=> source produced no result.
Trying source 6 (type inline) of library mysql ...
mysql.h not found in ["C:/Program Files/MySQL/MySQL Connector C++ 8.0/include"] and global paths.
=> source produced no result.
Trying source 7 (type inline) of library mysql ...
=> source failed condition '!config.win32'.
Trying source 8 (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 ...
oci.h not found in [] and global paths.
=> source produced no result.
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 E:\Programme\qt\Tools\5.15.0\Src\qtbase\src\plugins\sqldrivers\config.tests\odbc && E:\Programme\qt\Tools\5.15.0\mingw81_64\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.7.25-winx64\lib C:\Utils\postgresql\pgsql\lib" "INCLUDEPATH += C:\openssl\include C:\Utils\my_sql\mysql-5.7.25-winx64\include C:\Utils\postgresql\pgsql\include" "QMAKE_USE += odbc" "QMAKE_LIBS_ODBC = -lodbc32" E:/Programme/qt/Tools/5.15.0/Src/qtbase/src/plugins/sqldrivers/config.tests/odbc
- cd /d E:\Programme\qt\Tools\5.15.0\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 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.7.25-winx64\include -IC:\Utils\postgresql\pgsql\include -IE:\Programme\qt\Tools\5.15.0\mingw81_64\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.7.25-winx64\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 ...
libpq-fe.h not found in [] and global paths.
=> source produced no result.
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 ...
sqlite.h not found in [] and global paths.
=> source produced no result.
test config.sqldrivers.libraries.sqlite2 FAILED
looking for library tds
Trying source 0 (type sybaseEnv) of library tds ...- cd /d E:\Programme\qt\Tools\5.15.0\Src\qtbase\src\plugins\sqldrivers\config.tests\tds && E:\Programme\qt\Tools\5.15.0\mingw81_64\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.7.25-winx64\lib C:\Utils\postgresql\pgsql\lib" "INCLUDEPATH += C:\openssl\include C:\Utils\my_sql\mysql-5.7.25-winx64\include C:\Utils\postgresql\pgsql\include" "QMAKE_USE += tds" "QMAKE_LIBS_TDS = -lNTWDBLIB" E:/Programme/qt/Tools/5.15.0/Src/qtbase/src/plugins/sqldrivers/config.tests/tds
- cd /d E:\Programme\qt\Tools\5.15.0\Src\qtbase\src\plugins\sqldrivers\config.tests\tds && set MAKEFLAGS=& mingw32-make clean && set MAKEFLAGS=& mingw32-make
del main.o
E:\Programme\qt\Tools\5.15.0\Src\qtbase\src\plugins\sqldrivers\config.tests\tds\main.o konnte nicht gefunden werden
g++ -c -fno-keep-inline-dllexport -O2 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.7.25-winx64\include -IC:\Utils\postgresql\pgsql\include -IE:\Programme\qt\Tools\5.15.0\mingw81_64\mkspecs\win32-g++ -o main.o main.cpp
main.cpp:2:10: fatal error: sybfront.h: No such file or directory
#include <sybfront.h>
^~~~~~~~~~~~
compilation terminated.
mingw32-make: *** [Makefile:498: 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 FAILEDand this is the config ...
-
@JonnyQB said in QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7 I need QMYSQL:
mysql.h not found in ["C:/Program Files/MySQL/MySQL Connector C++ 8.0/include"]
So is your mysql.h in this directory or did you install it in another place?
-
@Christian-Ehrlicher
i tried 2 seperate connects -
@JonnyQB said in QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7 I need QMYSQL:
C:/Program Files/MySQL/MySQL Connector C++ 8.0/include
So why do you pass the wrong path to qmake then??