August 24, 2010

Evan-XG Evan-XG
Lab Rat
23 posts

Problem using Mysql driver

 

I have suffered in 4 days to compile mysql driver . i succeded to do so and try my first sample app that connected correctly to my sql . the next day i wanted to start my related project on mysql (a db manager) i tryed to connect it gave me this message

MYSQL Not Loaded

Available driver SQLITE3 SQLITE ODBC MYSQL

I read the doc and try to solve with no success . then I uninstall completly my Qt, mysql and clean up things like path

I reintall a fresh Qt creator, compile successfully mysql driver. Now this is the message I got

MYSQL Not Loaded

Available driver SQLITE3 SQLITE ODBC

Meaning that mysql drivers is not available any more . the plugin path is correct I have tryed all the attemp in the doc .

please any help would be welcome.

 Signature 

Evan-XG

10 replies

August 24, 2010

harryF harryF
Lab Rat
33 posts

set the environment variable QT_DEBUG_PLUGINS to 1, what kind of output do you get?

 Signature 

// happy hacking

August 24, 2010

Evan-XG Evan-XG
Lab Rat
23 posts

as you said I ahev done that now using this

  1. #include <QtGui/QApplication>
  2. #include <QtSql>
  3.  
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7.     QApplication a(argc, argv);
  8.  
  9.     QSqlDatabase::addDatabase("MYSQL");
  10.  
  11.  
  12.     return a.exec();
  13. }

I am getting this error now :

Starting C:\Users\Administrator\Desktop\testger-build-desktop\release\testger.exe…
QFactoryLoader::QFactoryLoader() looking at “C:/Qt/2010.04/qt/plugins/sqldrivers/libqsqlite4.a”
“The file ‘C:/Qt/2010.04/qt/plugins/sqldrivers/libqsqlite4.a’ is not a valid Qt plugin.” not a plugin
QFactoryLoader::QFactoryLoader() looking at “C:/Qt/2010.04/qt/plugins/sqldrivers/libqsqlited4.a”
“The file ‘C:/Qt/2010.04/qt/plugins/sqldrivers/libqsqlited4.a’ is not a valid Qt plugin.” not a plugin
QFactoryLoader::QFactoryLoader() looking at “C:/Qt/2010.04/qt/plugins/sqldrivers/libqsqlmysql4.a”
“The file ‘C:/Qt/2010.04/qt/plugins/sqldrivers/libqsqlmysql4.a’ is not a valid Qt plugin.” not a plugin
QFactoryLoader::QFactoryLoader() looking at “C:/Qt/2010.04/qt/plugins/sqldrivers/libqsqlmysqld4.a”
“The file ‘C:/Qt/2010.04/qt/plugins/sqldrivers/libqsqlmysqld4.a’ is not a valid Qt plugin.” not a plugin
QFactoryLoader::QFactoryLoader() looking at “C:/Qt/2010.04/qt/plugins/sqldrivers/libqsqlodbc4.a”
“The file ‘C:/Qt/2010.04/qt/plugins/sqldrivers/libqsqlodbc4.a’ is not a valid Qt plugin.” not a plugin
QFactoryLoader::QFactoryLoader() looking at “C:/Qt/2010.04/qt/plugins/sqldrivers/libqsqlodbcd4.a”
“The file ‘C:/Qt/2010.04/qt/plugins/sqldrivers/libqsqlodbcd4.a’ is not a valid Qt plugin.” not a plugin
QFactoryLoader::QFactoryLoader() looking at “C:/Qt/2010.04/qt/plugins/sqldrivers/qsqlite4.dll”
keys (“QSQLITE”)
QFactoryLoader::QFactoryLoader() looking at “C:/Qt/2010.04/qt/plugins/sqldrivers/qsqlited4.dll”
“The plugin ‘C:/Qt/2010.04/qt/plugins/sqldrivers/qsqlited4.dll’ uses incompatible Qt library. (Cannot mix debug and release libraries.)” not a plugin
QFactoryLoader::QFactoryLoader() looking at “C:/Qt/2010.04/qt/plugins/sqldrivers/qsqlmysql4.dll”
keys (“QMYSQL3”, “QMYSQL”)
QFactoryLoader::QFactoryLoader() looking at “C:/Qt/2010.04/qt/plugins/sqldrivers/qsqlmysqld4.dll”
“The plugin ‘C:/Qt/2010.04/qt/plugins/sqldrivers/qsqlmysqld4.dll’ uses incompatible Qt library. (Cannot mix debug and release libraries.)” not a plugin
QFactoryLoader::QFactoryLoader() looking at “C:/Qt/2010.04/qt/plugins/sqldrivers/qsqlodbc4.dll”
keys (“QODBC3”, “QODBC”)
QFactoryLoader::QFactoryLoader() looking at “C:/Qt/2010.04/qt/plugins/sqldrivers/qsqlodbcd4.dll”
“The plugin ‘C:/Qt/2010.04/qt/plugins/sqldrivers/qsqlodbcd4.dll’ uses incompatible Qt library. (Cannot mix debug and release libraries.)” not a plugin
QSqlDatabase: MYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL3 QMYSQL QODBC3 QODBC

 Signature 

Evan-XG

August 24, 2010

harryF harryF
Lab Rat
33 posts

The driver name for the Qt MySQL driver is “QMYSQL”, not “MYSQL”.

 Signature 

// happy hacking

August 24, 2010

Evan-XG Evan-XG
Lab Rat
23 posts

change it but the same output

 Signature 

Evan-XG

August 24, 2010

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

Output in your last post is simply a debug and it is ok that it contains all this strings. Is behavior changed or still database is unavailable?

August 25, 2010

Evan-XG Evan-XG
Lab Rat
23 posts

surprisingly it’s come up . thanks a lot but i think they are subtle things going on . thanks very much

 Signature 

Evan-XG

September 10, 2010

red_eye red_eye
Lab Rat
1 posts

I too am struggling with the QMYSQL driver issue in building a Windoze application. A first with Qt 4.6 commercial & VS 2008, I follow the plugin instrictions in Assistant, the “driver is not loaded” and the Assistant says it’s usually an issue with the build key. Perhaps someone could suggest a solution to this.

In Linux I recompiled the Qt source with Mysql in the configuration or something like that, and life was good. Do I have to do the same in Winblows too?

This shouldn’t be so difficult. Come on Qt experts, let go of the little details please.

September 13, 2010

Evan-XG Evan-XG
Lab Rat
23 posts

I solved mine on a french source. I used qt creator to built on the commande line. but really this drivers gives some unexpected result from time to time . i succed to built and test it, 2 days later i tried to work on my project it wsa not working any more . my source is Here [giminik.developpez.com]

its in french but to summarize . you need to install mysql with the header files .

assuming u have Mingw install do this on cammand line

  1. cd C:\MySQL-5.0\lib\opt
  2. reimp -d libmysql.lib

note sometimes reimp is not in your mingw bin folder, so u need Download [ftp-developpez.com]

or in mingw utilities folder from sourgeforge.net

after u need to do this

  1. dlltool -k --input-def libmysql.def --dllname libmysql.dll --output-lib libmysql.a
this process is to make the lib file compatible with mingw implementation.
now u ill need to compile the mysql driver by linking to the lib file that was created in the last process . it is the as in the documentation, but to make u’r life easier i would recomand u to use qt command line tool Mingw . if for some reason u d’ont want there is always a way around. just beaware that compiling with eithercompiler can bring your error. my solution was to clean up everithing and compile again

 Signature 

Evan-XG

September 27, 2010

s.frings s.frings
Lab Rat
40 posts

After upgrade to QT 4.7 on windows, I encountered a new problem which I did not have previously: reimp 0.3 and also 0.41 does not work with current version 6.02 of libmysql.dll:

reimp -d libmysql.dll
reimp: libmysql.dll: invalid or corrupt import library

How can I compile the mysql plugin now?

September 29, 2010

s.frings s.frings
Lab Rat
40 posts

My error was that I tried to run reimp on the dll file, but I should use the lib file instead. Oops!

 
  ‹‹ problem building embedded qt version      QT Creator 2.0 pro file issue ››

You must log in to post a reply. Not a member yet? Register here!