Вынужден использовать старую версию QT под виндой. При сборке ругается: | Код | QSqlDatabase: QMYSQL3 driver not loaded QSqlDatabase: available drivers:
|
Код: | Код | #include <QApplication.h> #include <QSQLDataBase.h> #include <QMessageBox.h>
void showLibs(QApplication& appl) { QStringList::const_iterator constIterator; for (constIterator = appl.libraryPaths().constBegin(); constIterator != appl.libraryPaths().constEnd(); ++constIterator) { QMessageBox::information(NULL, "Library path", (*constIterator)); } }
int main( int argc, char **argv ) { QApplication app( argc, argv); app.addLibraryPath("C:/Distrib/3.3.3/plugins/sqldrivers");
QSqlDatabase *defaultDB = QSqlDatabase::addDatabase( "QMYSQL3" );
defaultDB->setDatabaseName( "db_test" ); defaultDB->setUserName( "root" ); defaultDB->setPassword( "god" ); defaultDB->setHostName( "localhost" );
showLibs(app);
if ( !defaultDB->open() ) { defaultDB->lastError().showMessage(); return 1; }
// Database successfully opened; // we can now issue SQL commands. return 0; }
|
QT 3.3.3 поставлено методом "перенесли папку и прописали пути", так что в этом тоже может быть косяк :-( Хотя проект без подобных вещей собирается, то есть студия все нужные пути находит. Драйвер к mysql пришлось собрать из исходников. Собирал так: | Код | C:\Distrib\3.3.3\plugins\src\sqldrivers\mysql>qmake -o Makefile "INCLUDEPATH+=C:\MySQL\include" "LIBS+=C:\MySQL\lib\opt\libmysql.lib" mysql.pro
C:\Distrib\3.3.3\plugins\src\sqldrivers\mysql>nmake
|
| Код | C:\Distrib\3.3.3\plugins\src\sqldrivers\mysql>nmake
Microsoft (R) Program Maintenance Utility Version 8.00.50727.42 Copyright (C) Microsoft Corporation. All rights reserved.
link /NOLOGO /DELAYLOAD:comdlg32.dll /DELAYLOAD:oleaut32.dll /DELAYLOAD:winmm.dll /DELAYLOAD:wsock32.dll /DELAYL OAD:winspool.dll /DELAYLOAD:opengl32.dll /SUBSYSTEM:WINDOWS /DLL /LIBPATH:"c:\Distrib\3.3.3\lib" /OUT:..\..\..\sqldriver s\qsqlmysql.dll @C:\Temp\nmF2.tmp Creating library ..\..\..\sqldrivers\qsqlmysql.lib and object ..\..\..\sqldrivers\qsqlmysql.exp LINK : warning LNK4199: /DELAYLOAD:comdlg32.dll ignored; no imports found from comdlg32.dll LINK : warning LNK4199: /DELAYLOAD:oleaut32.dll ignored; no imports found from oleaut32.dll LINK : warning LNK4199: /DELAYLOAD:winmm.dll ignored; no imports found from winmm.dll LINK : warning LNK4199: /DELAYLOAD:wsock32.dll ignored; no imports found from wsock32.dll LINK : warning LNK4199: /DELAYLOAD:winspool.dll ignored; no imports found from winspool.dll LINK : warning LNK4199: /DELAYLOAD:opengl32.dll ignored; no imports found from opengl32.dll
|
Собственно, вопросы: - чяднт?
- почему список драйверов пустой? (в папке с драйверами есть как минимум уже собранные db2, sqlite и odbc)
- как убедиться, что пути - верные?
- может, где-то есть скомпиленная под винду эта библиотека? Или если собрать qt с нуля компилёром от МС, будет работать?
|