首页 > 解决方案 > 未加载 Qt QMYSQL 驱动程序和可用驱动程序:(为空)(Linux)

问题描述

我构建了 QMYSQL 驱动程序,但是当我运行我的程序时出现此错误:

QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: 

这是我的so文件已编译的路径:

/home/uia53314/Qt5.13.0/5.13.0/Src/qtbase/src/plugins/sqldrivers/plugins/sqldrivers
 ls :
libqsqlite.so  libqsqlite.so.debug  libqsqlmysql.so  libqsqlmysql.so.debug


 /Qt5.13.0/5.13.0/Src/qtbase/src/plugins/sqldrivers$ ls:


config.cache    libqsqlite.so          psql
config.log      libqsqlite.so.debug    qsqldriverbase.pri
config.opt      libqsqlmysql.so        qtsqldrivers-config.h
config.summary  libqsqlmysql.so.debug  qtsqldrivers-config_p.h
config.tests    Makefile               qtsqldrivers-config.pri
configure.json  mkspecs                README
configure.pri   mysql                  sqldrivers.pro
db2             oci                    sqlite
ibase           odbc                   sqlite2
lib             plugins                tds

在 /Qt5.13.0/5.13.0/Src/qtbase/src/plugins/sqldrivers 中运行 qmake sqldrivers.pro 给我:

配置摘要:

Qt Sql Drivers:
  DB2 (IBM) .............................. no
  InterBase .............................. no
  MySql .................................. yes
  OCI (Oracle) ........................... no
  ODBC ................................... no
  PostgreSQL ............................. no
  SQLite2 ................................ no
  SQLite ................................. yes
    Using system provided SQLite ......... no
  TDS (Sybase) ........................... no

Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into '/home/uia53314/Qt5.13.0/5.13.0/gcc_64'.

Prior to reconfiguration, make sure you remove any leftovers from
the previous build.

我需要在我的个人资料中添加一些东西以使程序看到驱动程序:

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
QT       += core gui charts sql

TARGET = WebmPlayer
TEMPLATE = app
CONFIG += c++11


QTPLUGIN += qsqlmysql

DEFINES += QT_DEPRECATED_WARNINGS


#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0


TEMPLATE = app

INCLUDEPATH += /usr/local/include/
LIBS += -L/usr/local/lib  -lcurlpp -lcurl
LIBS += -L/usr/local/lib/x86_64-linux-gnu  -lmysqlclient

CONFIG += console link_pkgconfig
#CONFIG -= app_bundle qt

PKGCONFIG += vpx opus vorbis

INCLUDEPATH = . libwebm
DEPENDPATH  = . libwebm

标签: mysqlqt

解决方案


推荐阅读