Mysql plugin generated but cannot be loaded



  • Hi guys, I'm new to QT. Im using the latest QT IDE at the moment (Qt Creator version 2.1, QT 4.7.3). I have compiled mysql plugin and generated qsqlmysqld4.dll and qsqlmysql4.dll. But when I ran the program, I got the error "Driver not loaded". From the application output, I got the information :

    QSqlDatabase: available drivers: QSQLITE

    So I know it means mysql driver is not available for my program but i don't know why. And how can I make it available here.
    I have copied the file qsqlmysqld4.dll and qsqlmysql4.dll to the following path:
    D:\QtSDK\Desktop\Qt\4.7.3\mingw\plugins\sqldrivers
    I have also copied the file libmysql.dll to:
    D:\QtSDK\Desktop\Qt\4.7.3\mingw\bin

    Thanks in advance!



  • Try putting libmysql.dll in your global PATH in Control Panel/System/Advanced System Settings/Environment variables, then restart Qt Creator. Does that help? Alternatively, you can try putting libmysql.dll in the same folder as the Qt dlls in yourQtDirectory/bin.



  • [quote author="sigrid" date="1304670651"]Try putting libmysql.dll in your global PATH in Control Panel/System/Advanced System Settings/Environment variables, then restart Qt Creator. Does that help? Alternatively, you can try putting libmysql.dll in the same folder as the Qt dlls in yourQtDirectory/bin. [/quote]

    Thank you very much for your reply. I put the libmysql.dll to my executable file folder and it is now working. But I wonder why it dosen't work when I put it in D:\QtSDK\Desktop\Qt\4.7.3\mingw\bin, where this path is in system environment variable PATH.



  • May I ask how did you compile the MySQL driver for Qt Creator 4.7.3 ?

    I can only find tutorials for old versions...

    That would be kind !



  • bq. Thank you very much for your reply. I put the libmysql.dll to my executable file folder and it is now working. But I wonder why it dosen’t work when I put it in D:\QtSDK\Desktop\Qt\4.7.3\mingw\bin, where this path is in system environment variable PATH.

    This seems to be caused by the following bug:

    http://bugreports.qt.nokia.com/browse/QTBUG-18003

    where the qtvars.bat overrides the global PATH and causes your modifications to the PATH to be ignored.



  • [quote author="doobinay" date="1305005095"]May I ask how did you compile the MySQL driver for Qt Creator 4.7.3 ?

    I can only find tutorials for old versions...

    That would be kind ![/quote]

    Building mysql driver for the old versions is actually quite similar to the new version. The latest qt sdk separates the files for mingw and visual studio.net environments. If you use mingw as your compiler, QtSDK\Desktop\Qt\4.7.3\mingw is your "QTDIR". Keep this in mind and follow the old tutorial and you will get the mysql driver compiled.



  • [quote author="sigrid" date="1305010321"]bq. Thank you very much for your reply. I put the libmysql.dll to my executable file folder and it is now working. But I wonder why it dosen’t work when I put it in D:\QtSDK\Desktop\Qt\4.7.3\mingw\bin, where this path is in system environment variable PATH.

    This seems to be caused by the following bug:

    http://bugreports.qt.nokia.com/browse/QTBUG-18003

    where the qtvars.bat overrides the global PATH and causes your modifications to the PATH to be ignored.[/quote]

    Thanks again for all your help!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.