QMYSQL Driver not loaded in Ubuntu
-
Hi I'm trying to build a program that connect on MySQL, i have this error "QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7"But i already "libmysqlclient.so.20" and "libqsqlmysql.so" in my sqldrivers folder. Please do help me, I'm a beginner in QT Programming. Sorry for my grammar.
I'm using this code
QSqlDatabase db1 = QSqlDatabase::addDatabase( "QMYSQL" ); db1.setHostName("127.0.0.1"); db1.setPort(8080); db1.setDatabaseName( "sample" ); db1.setUserName( "root" ); db1.setPassword( "" ); if( !db1.open() ) { qDebug() << db1.lastError(); qFatal( "Failed to connect." ); } qDebug( "Connected!" );
OS : Ubuntu 16.04
QT Ver : Qt 5.12.0 -
@Double-A Set QT_DEBUG_PLUGINS env variable and start your app - you should see why the plug-in was not loaded.
See "Debugging Plugins" in https://doc.qt.io/qt-5/deployment-plugins.html -
@jsulm i got this error
QLibraryPrivate::loadPlugin failed on "/home/pc/Qt/5.12.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so" : "Cannot load library /home/pc/Qt/5.12.0/gcc_64/plugins/sqldrivers/libqsqlmysql.so: (libmysqlclient.so.18: cannot open shared object file: No such file or directory)"
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7 -
@Double-A said in QMYSQL Driver not loaded in Ubuntu:
libmysqlclient.so.18
As the error says it can't find libmysqlclient.so.18
Also don't forget that on UNIX/Linux it is not enough to put the lib in same directory like on Windows.