MySQL driver not loaded in other computers.



  • I made a Qt application with mysql successfully.

    And then I want test it in other computers.

    I zip debug folder with required dlls and send it to my friends.

    Application succesfully starts and working.

    But, when accessing MySQL it says driver not loaded!

    Did I miss something???



  • The SQL database drivers are implemented as Qt plugins.
    All Qt plugins are in the "plugins" folder of your Qt installation. In that folder there is a subfolder called sqldrivers and this folder contains a file looking like "mysql.dll" which is the driver plugin for MySQL.
    To solve your issue, you must:
    1/ Create a "plugins" folder in your ZIP so that it will be next to your executable
    2/ Create a "sqldrivers" folder in that "plugins" folder and copy the "mysql.dll" MySQL driver in that folder
    3/ In your main function, call @QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath())@

    This will tell Qt your application to look for plugins in the executable directory. See "this page":http://qt-project.org/doc/qt-4.8/qcoreapplication.html#libraryPaths for more information on Qt, plugins and library paths.



  • Hi,
    Create a “sqldrivers” folder in the application's directory, then copy the xxxx.dll plugin to it is enough.
    No "plugins" directory is needed. No "addLibraryPath(...)" is needed.



  • God bless rcari and 1+1=2 !

    Thank you for your kind answers ;)

    It really works, and thank you two so much! :)


Log in to reply
 

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