PDA

View Full Version : Step by Step MySQL Plugin... what's next step?



chaosgeorge
4th November 2006, 15:53
Hi there, well i have just got the mf mysql plugin now i got in <qtdir>\plugins\sqldrivers\ the holly qsqlmysql.dll what's next for making it work? and dont get the "Driver not loaded" message?
i guess i have to... configure -plugin-sql-mysql ?
uhm the -I and -L parameters are needed?
thanks

wysota
4th November 2006, 16:12
Install MySQL to a place where Windows (I guess you're using Windows) can find it. You don't need to recompile anything if you already have the dll. If you do that correctly, you shouldn't need to do anything more.

jacek
4th November 2006, 16:14
i guess i have to... configure -plugin-sql-mysql ?
uhm the -I and -L parameters are needed?
No, these are required to compile the plugin.

Did you compile that plugin yourself? Qt might not want to load a plugin that was built using different compiler or for different Qt version. Also make sure that Qt can find all MySQL DLLs (DependencyWalker (http://dependencywalker.com) might be helpful) and search the forum as this topic was discussed already.

chaosgeorge
4th November 2006, 16:31
ehhh i just did the thing for converting the library to a version mingw can use and i did the make thing in the src\plugins\sqldrivers\mysql so how i use the dependencyWalker or make sure qt finds the dll? and mysql is installed in <root>\mysql
sorry for the dummie questions
thanks

jacek
4th November 2006, 16:44
how i use the dependencyWalker or make sure qt finds the dll?
Just run it, open qsqlmysql.dll and it should tell you whether it could find all DLLs or not. Then you will have to copy all missing DLLs from \mysql directory to a place where windows will find it (for example to the same directory as the executable).

Also if you compile your application in debug mode, you need qsqlmysqld.dll instead of qsqlmysql.dll.

chaosgeorge
4th November 2006, 17:06
it says it depends of msjava.dll no luck finding it in my hd, where is it?

jacek
4th November 2006, 17:14
it says it depends of msjava.dll no luck finding it in my hd, where is it?
Forget about that one. You should look only for those that are connected to MySQL.

chaosgeorge
4th November 2006, 17:19
ok then i run it i still get the Driver not loaded error from db.lasterror().text using




{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
..
db things
....
if(!db.open()){
QMessageBox::critical(0, QObject::tr("Error"),
db.lastError().text());
return false;
}
}

chaosgeorge
4th November 2006, 17:24
By the way QSqlDatabase::drivers(); returns just QSQLITE, QODBC3, QODBC is that ok?

wysota
4th November 2006, 18:23
By the way QSqlDatabase::drivers(); returns just QSQLITE, QODBC3, QODBC is that ok?

Yes. It means it is able to use those drivers. Mysql driver is somehow unusable (due to missing dependencies probably) so it is not listed here. Once you fulfill dependencies, QMYSQL will get listed here as well.

chaosgeorge
4th November 2006, 18:45
uhm well actually i got all dependencies ok except msjava.dll but still dont work, what would be the difference using configure to build the plugin? that should work too? using -I ..\mysqlinclude and -L ..\mysqllib\opt

chaosgeorge
4th November 2006, 19:53
:crying: the last option didnt work either there are a lot of undefined references at qsql_mysql.cpp when creating library libqsqlmysql.a any ideas? thanks

o well it worked now, i forgot make-installing the plugin when i built it, so it's now still configuring Qt i guess it will take some minutes... but i have a question, i just deleted the qsqlite.dll from the plugins directory (just to see what happened :D) but databases() still returned the driver is loaded why is that?

jacek
4th November 2006, 20:59
ok then i run it i still get the Driver not loaded error from db.lasterror().text using




{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
...
}

Do you create QCoreApplication or QApplication instance before you try to use the database?

chaosgeorge
4th November 2006, 21:03
uhm yes i guess i use a function in a class to test the connection but after QApplication



int main(int argc, char *argv[])
{

QApplication a(argc, argv);
Q_INIT_RESOURCE(resources);
CMain w;

if( !w.createConnection() )
return 1;
w.show();
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();

}

jacek
4th November 2006, 21:10
uhm yes i guess i use a function in a class to test the connection but after QApplication
QCoreApplication is responsible for plugin loading, so if you won't create QCoreApplication or QApplication plugins won't be accessible.

Have you seen any references to MySQL DLLs in Dependency Walker?

chaosgeorge
4th November 2006, 21:15
Have you seen any references to MySQL DLLs in Dependency Walker?

Yes i got all references in my release directory and the mysql dll but no luck


QCoreApplication is responsible for plugin loading, so if you won't create QCoreApplication or QApplication plugins won't be accessible.

so i must use QCoreApplication instead of QApplication?

wysota
4th November 2006, 23:48
so i must use QCoreApplication instead of QApplication?
QApplication inherits QCoreApplication.

chaosgeorge
5th November 2006, 02:37
ok i made the plugin through make and by configure but no success loading it by Qt any ideas?

chaosgeorge
5th November 2006, 04:25
Oh my wtf hmfs this at least!!!!!!!!!!!!!! i got it!!!!!!!!!!! the problem was... uhm i dont know what it was but i reinstalled mysql, "mingw-ized" the libs "make-ized" the libs to build the plugin "make-installed" the plugin and taratatannn Qt loaded the driver !!!!!! the last option is what worked at least damn o well now i have to solve connection problems to my remote server LOL :p thanks everyone

uhm wtf uhm it looks like it only works in the visual studio command prompt environment in qt command prompt it loads the driver but i get the driver not loaded error right after any ideas? by the way i used nmake instead of make

wysota
5th November 2006, 09:14
You are missing some environment variables (from MySQL?) and you probably mixed up two different builds - MSVC (nmake) one and MinGW (make) one.

chaosgeorge
5th November 2006, 15:32
Uhm what environment variables could be? and doesn't matter how i build the program (nmake or make) it just works from any cmd window but qt's cmd window, do i have to add env vars to qt's cmd? how?