当前位置:网站首页>Qsqldatabase: solution of qmmysql driver not loaded
Qsqldatabase: solution of qmmysql driver not loaded
2022-07-24 16:45:00 【SakamataZ】
Yesterday I helped people set up an attendance management project , No more details , Anyway, I set up the project , Get ready sql Environmental Science , Tips :QSqlDatabase: QMYSQL driver not loaded, then debug Up to now …
No matter how , I give my solution , I hope this article can help you .
Qt Connect MySql You need to connect to Qt Database plug-in for , Then connect to MySql Dynamic library , To be able to use MySql.
The dynamic library plug-in is mysql Self contained , We need to compile the database plug-in by ourselves .
Although a little cumbersome , But it's not difficult .
List of articles
Install and configure environment variables

here Be sure to check Source Source folder For later compilation .
No matter the runtime of your project (kit) What is it? , The next steps are the same . Only the database plug-in and dynamic library plug-in are placed in different positions , Which library does your project use , Just put the database plug-in and dynamic library plug-in QT Which library .
I won't say more about environment variable configuration , There must be this bug All have been configured .
compile mysql drive
Open folder D:\QT\5.14.2\Src\qtbase\src\plugins\sqldrivers\mysql
Of course, we may have different installation positions , without Src First step .
stay Qt Open in mysql.pro
Comment out QMAKE_USE += mysql, Add three lines of code :
win32:LIBS += -LD:\mysql\lib\ -llibmysql
INCLUDEPATH += D:/MySql/include
DEPENDPATH += D:/MySql/include
The first line is to use \mysql\lib\ Under the libmysql Folder , The second and third lines are using /MySql/include Folder
The effect is as follows :
Watch out! , There must be no spaces in the path
If mysql There are spaces in the path , It needs to be reloaded . So it's really troublesome
after structure file , At the root D:\plugins\sqldrivers Find three or four files under :
Generated qsqlmysql.dll qsqlmysqld.dll Copy to Qt Corresponding mingw Of sqldrivers in .
Here are three , Tests can also .
Copy sql Dynamic library
Copy mysql Dynamic library , take mysql/lib Medium libmysql.dll ( Dynamic library ) Copy to Qt Corresponding compiler bin Under the table of contents
Test connection
New projects , Or there are already non conflicting projects
stay .pro Add... To the document QT += sql
Use the following code to print the available database version
#include "mainwindow.h"
#include <QDebug>
#include <QApplication>
#include <QtSql/QtSql>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QStringList drivers = QSqlDatabase::drivers(); // Get the currently available database drivers
foreach(QString driver, drivers)
qDebug() << driver;
MainWindow w;
w.show();
return a.exec();
}
appear :QMYSQL
Success .
Please leave a message if you have any questions , I will reply in six hours , Probably .
边栏推荐
- EF miscellaneous
- [LeetCode]75.颜色分类——题解(执行用时击败90% ,内存消耗击败 78%)
- 荣耀CEO赵明:单一厂商很难实现全场景产品覆盖
- Sword finger offer 48. the longest substring without repeated characters
- 【零基础】充分理解WebGL(八)
- AMD锐龙7000预计9月15日上市 3D缓存版还要再等等
- [machine learning basics] - another perspective to explain SVM
- Hping3 installation and use
- Explain Apache Hudi schema evolution in detail
- Duplicate content in lookup table
猜你喜欢

ArcGIS create vector

Win10 download address

jvm类加载子系统

Jing Wei PS tutorial: basic part a

1184. 公交站间的距离

IP day 13 notes
![为什么被调函数内部不能用 sizeof(arr) / size(arr[0]) 计算数组长度?](/img/e6/1d2213f3eb9bd0ff537a66d2b01f98.png)
为什么被调函数内部不能用 sizeof(arr) / size(arr[0]) 计算数组长度?

Comparison of array and object merging methods assign, merge, defaults, defaultsdeep in lodash

剑指 Offer 22. 链表中倒数第k个节点

JVM class loading subsystem
随机推荐
1184. 公交站间的距离
Creation and inheritance of JS class
图片浏览器?Qt也可以实现!
Matlab writes excel string and number merging
Dongfang Guangyi refuted the rumor late at night, saying that the news that the hammer was filed for investigation was untrue!
随笔记:同步、异步和微任务、宏任务的打印顺序
With regard to performance testing, dry goods hit "suggestions collection"
QML coding specification
剑指 Offer 25. 合并两个排序的链表
【南京农业大学】考研初试复试资料分享
1184. Distance between bus stops
15. ARM embedded system: how to debug single board with PC
ArcGIS create vector
[zero basis] fully understand webgl (VIII)
小端格式和大端格式(Little-Endian&Big-Endian)
Why should we launch getaverse?
709. Convert to lowercase letters
我们为什么要推出Getaverse?
EventLoop event loop mechanism
Envi5.3 open GF-1 WFV data