PDA

View Full Version : error connecting to MySQL



collycrk
9th April 2015, 18:49
I've installed QT 5.4.1 and working in QT Creator 3.3.2.

I'm getting this error code:
C:\www\QtGui\testMysqlConnection\main.cpp:28: error: undefined reference to `_imp___ZN12QSqlDatabaseC1Ev'

line 28 has these lines of code (qDebug() << "Connected!";
QSqlQuery query;
query.exec("SELECT fname FROM client");
)
The includes:
#include <QCoreApplication>
#include <QtSql/QSql>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlDriver>
#include <QtSql/QSqlQuery>
#include <QDebug>

Thanks for your help.

ChrisW67
9th April 2015, 21:32
That is a linker error, not an error connecting to MySql.

Have you added


QT += sql

To your pro file and rerun qmake?
http://doc.qt.io/qt-5/qtsql-index.html

collycrk
18th August 2015, 17:38
Thanks for the reply Chris, my apologizes for the late response.
I have solved the mysql connecting. You were right I did not have QT += sql in pro among other things.
Thanks again.
I'm also now using SQLite database and for my purposes I like better.