c++ - No MYSQL Connect with QT CREATOR libmysqlclient_16 -
i've started programming in c++
qt 5.4
i'm having problems when making connection mysql. iseem have problems driver.
os: ubuntu 14.04
qt version > 5.1
this error:
"can not load library /home/diana/qt5.1.1/5.1.1/gcc_64/plugins/sqldrivers/libqsqlmysql.so : ( /usr/lib/libmysqlclient_r.so.16 : version ` libmysqlclient_16 'not found (required /home/diana/qt5.1.1/5.1.1/gcc_64/plugins/sqldrivers/libqsqlmysql.so ) ) " ( " qsqlite " " qpsql " " qpsql7 " ) driver not found
.pro file:
qt + = core gui qt + = sql qtplugin + = qsqlmysql
main.cpp
#include "mainwindow.h" #include <qapplication> #include <qtwidgets> #include <qtsql> #include <qsqldatabase> #include <qsqldriver> #include <qsqlerror> #include <qsqlquery> #include <qsqldrivercreator> #include <qsqldriverplugin> #include <qtplugininstancefunction> #include <qpluginloader> #include <qtplugin> int main(int argc, char *argv[]) qapplication a(argc, argv); mainwindow w; qpluginloader loader("/home/diana/qt5.1.1/5.1.1/gcc_64/plugins/sqldrivers/libqsqlmysql.so"); loader.load(); qdebug()<<loader.errorstring(); qdebug() << qsqldatabase::drivers(); if (qsqldatabase::isdriveravailable("qmysql")){ qsqldatabase db = qsqldatabase::adddatabase("qmysql", "test"); db.sethostname("localhost"); db.setdatabasename("school"); db.setusername("root"); db.setpassword("elchaka"); if (db.open()){ qdebug()<<"conected;" }else{ qsqlerror mensaje = db.lasterror(); qdebug()<<mensaje; } }else{ qdebug()<<("not found driver"); } w.show(); return a.exec(); }
Comments
Post a Comment