gpt4 book ai didi

mysql - Qt 库 'mysql' 未定义

转载 作者:太空宇宙 更新时间:2023-11-04 11:50:20 25 4
gpt4 key购买 nike

当我运行这段代码时,Qt 与 MySql 的连接出现问题

    QSqlDatabase DBObject = QSqlDatabase::addDatabase("QMYSQL");
DBObject.setHostName("localhost");
DBObject.setDatabaseName("SingleDB");
DBObject.setUserName("root");
DBObject.setPassword("abc123");
bool ok = DBObject.open();

我得到了这个... QSqlDatabase:未加载 QMYSQL 驱动程序 QSqlDatabase: QMYSQL driver not loaded

我也这样做过:

sudo apt-get install libmysqlclient

/home/wrm/Qt/5.12.3/gcc_64/bin/qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro

这里我有这个错误:项目错误:库“mysql”未定义 enter image description here

有什么想法吗?

最佳答案

也许你需要安装mysql-devel

根据 Qt 文档 QMYSQL for MySQL 4 and higher :

How to Build the QMYSQL Plugin on Unix and macOS

You need the MySQL header files, as well as the shared library libmysqlclient.so. Depending on your Linux distribution, you may need to install a package which is usually called "mysql-devel".

关于mysql - Qt 库 'mysql' 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56248583/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com