PDA

View Full Version : Qt - mySQL installation agony under Ubuntu 14.04



val
7th May 2014, 20:54
After an unpleasant, to say the least, upgrade to Ubuntu 14.04 I found I needed to reformat and start over from scratch.
I did a fresh install of everything including Qt 5.2.1 (GCC 4.6.1, 64 bit) and MySQL server and client.
These seem to run fine.

But I have not been able to get QT to find MySQL.
Here is a trivial program:
.pro file
QT += core gui
QT += sql
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui

.cpp file:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtSql/QSql>
#include <QtSql/QSqlDatabase>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QSqlDatabase db =QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("mysql");
db.setUserName("root");
db.setPassword("");
db.open();
}

And upon execution it reports:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7

There has been lots of chatter about building the mysql plugin or about creating symbolic links to various .so files etc. related to this problem in the past.
I have tried lots of these without success.

I wonder if there is a UBUNTU 14.04 - Qt 5 solution? :)

Val