开发者

get_driver_instance() crashes with Qt

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\l开发者_如何转开发ib\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


From the documentation of MySQL Connector: "One problem that can occur is when the tools you use to build your application are not compatible with the tools used to build the binary versions of MySQL Connector/C++. Ideally you need to build your application with the same tools that were used to build the MySQL Connector/C++ binaries."

And to repeat the question of akira: Why don't you use the QMYSQL drivers?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜