Qt 4.2.2 with MinGW 3.4.2 (make is GNU 3.8) on XPpro SP2:
I'm trying a simple program that would connect through ODBC to my MSSQL200 server that runs on my machine;
the C:\Qt\4.2.2\demos\sqlbrowser\release\sqlbrowser.ex e does it perfectly but i want to do my own;
qmake -project and qmake -o Makefile -SQLTest.pro run Ok but after that the "make" first tells me: QtSql - no such file or directory and then after I insert in the Makefile.Debug the "-I"C:/Qt/4.2.2/include/QtSql" it returns a bunch of:
"undefined reference to `_imp___Z*****QSqlDatabase'"
here is my 2 source files:
main.cpp:
#include <QtGui>
#include <QtSql>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlError>
#include "connection.h"
int main(int argc, char *argv[])
{
if (!createConnection()) {
return 1;}
return app.exec();
}
#include <QtGui>
#include <QtSql>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlError>
#include "connection.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
if (!createConnection()) {
return 1;}
return app.exec();
}
To copy to clipboard, switch view to plain text mode
and connection.h:
#ifndef CONNECTION_H
#define CONNECTION_H
#include <QMessageBox>
#include <QSqlDatabase>
inline bool createConnection()
{
db.setHostName("localhost");
db.setDatabaseName("mydb");
db.setUserName("sa");
db.setPassword("password");
if (!db.open()) {
db.lastError().text());
return false;
}
return true;
}
#endif
#ifndef CONNECTION_H
#define CONNECTION_H
#include <QMessageBox>
#include <QSqlDatabase>
inline bool createConnection()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setHostName("localhost");
db.setDatabaseName("mydb");
db.setUserName("sa");
db.setPassword("password");
if (!db.open()) {
QMessageBox::warning(0, QObject::tr("Database Connection Error"),
db.lastError().text());
return false;
}
return true;
}
#endif
To copy to clipboard, switch view to plain text mode
make gives me exact same message even if i try to copy the entire contents of C:\Qt\4.2.2\demos\sqlbrowser\ into a different directory (how did it copile at install to begin with??)
my path is: "PATH=C:\Qt\4.2.2\bin;C:\Qt\4.2.2\lib;C:\Qt\4.2.2\ include;C:\MinGW\bin;C:\WINDOWS\System32"
any ideas?
Bookmarks