tags:

views:

28

answers:

0

Hi Folks,

I'm trying to User MySQL Connector/C++ with Qt, and had spent hours pulling my hairs on a problem. Here's a SIMPLE code to test out the connection:

int main(int argc, char *argv[]) {
QCoreApplication a(argc, argv);
cout << "aa" << endl;
sql::Driver *driver;
try {
    driver = get_driver_instance();
} catch(exception &e) {
    cout << e.what() << endl;
}

cout << "aa" << endl;
return a.exec();

}

It build and compiles fine, however whenever it calls get_driver_instance(), it crashes and just give me XXX.exe has stopped working.

I'm using Qt Creator, windows Vista, my .pro file is as follow:

QT       += core
QT       += sql

QT       -= gui

TARGET = friendsDB

CONFIG   += console
CONFIG   -= app_bundle

LIBS += "C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\debug\mysqlcppconn.lib"
INCLUDEPATH += "C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include"

TEMPLATE = app


SOURCES += main.cpp

Any light shed would be greatly appreciated, thanks