Home  >  Article  >  Database  >  How to manually compile QT without MySQL driver?

How to manually compile QT without MySQL driver?

PHPz
PHPzforward
2023-05-29 08:55:051153browse

Error code:

"QSqlDatabase: QMYSQL driver not loaded

,QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7"

There is no QMYSQL at all, so we need to compile it manually, which is very simple.

The author's configuration:

QT version: 5.13.0

The MySQL database uses SQLyog, a very simple MySQL database like excel Processing software

1. Download the 64-bit MySQL Community Server

How to manually compile QT without MySQL driver?

After downloading, unzip it for later use. No need to install it.

2. Find the qt installation directory in the QT installation directory and find: qt installation directory\5.13.0\Src\qtbase\src\plugins\sqldrivers\mysql\mysql.pro file, and then use QT Open the file.

Add in this file

#This path is the header file path of the mysql file that you just downloaded and decompressed
INCLUDEPATH ="D:\Software\mysql- 8.0.19-winx64\include"
#This path is the library file path of the mysql file that you just downloaded and decompressed
LIBS ="D:\Software\mysql-8.0.19-winx64\lib\libmysql.lib"

#In order to facilitate the search for library files that will be compiled in the future, add this statement to indicate the location of the compiled result output
DESTDIR = ../mysql/lib/

At the same time, QMAKE_USE = mysql must be blocked: as follows. If not blocked, it will prompt that the mysql library does not exist.

#QMAKE_USE = mysql

The specific picture is as shown

How to manually compile QT without MySQL driver?

3. Compile

Regardless of whether an error is output below, just click the small hammer on the lower left or Ctrl B to execute compilation

After the construction on the lower right is completed, there will be an additional lib folder in the mysql folder

4. Configuration

Open this lib folder , all 4 files in it are copied to your QT installation path\Qt5.13.0\5.13.0\mingw73_64\plugins\sqldrivers

As shown

How to manually compile QT without MySQL driver?

At this time, just connect to the MySQL database.

The above is the detailed content of How to manually compile QT without MySQL driver?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete