get_driver_instance()与Qt崩溃 [英] get_driver_instance() crashes with Qt
问题描述
我试图用Qt的用户MySQL连接器/ C ++,并花了几个小时拉我的头发一个问题。这里有一个SIMPLE代码来测试连接:
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();
}
我使用的是Qt Creator,windows Vista,my .pro文件如下:
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
推荐答案
MySQL连接器:可能出现的一个问题是,当您用于构建您的应用程序的工具不兼容与用于
的工具构建MySQL连接器/ C ++的二进制版本。理想情况下,您需要使用用于构建MySQL Connector / C ++二进制文件的相同工具来构建应用程序。
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."
并且重复akira的问题:你使用QMYSQL驱动程序吗?
And to repeat the question of akira: Why don't you use the QMYSQL drivers?
这篇关于get_driver_instance()与Qt崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!