Deploying app with sql plugins



  • Hello
    I've built an app that works perfect on my development machine (where I have full QT package installed). I decided to test it on the other machine so I've copied all files (including all required dll) to new machine and run the application.

    What does not work is a MySQL driver. Application runs without any problems, but when I try to connect to database it returns an error saying "Driver not loaded". So I've followed some thread on the forum & docs and copied sqldrivers plugin directory, added path to library paths, but it didn't help.

    The App is run from C:/slican.

    I think that the file which is required is the one from QT Installation path, so in my case it is:
    C:\Qt\5.4\mingw491_32\plugins\sqldrivers\qsqlmysql.dll

    On the test machine this file is now copied into:
    C:/slican/plugins
    C:/slican/sqldrivers
    C:/slican/plugins/sqldrivers

    I've checked library paths using this code in the main.cpp:
    QApplication a(argc, argv);
    QString str = a.applicationDirPath() + "/plugins";
    a.addLibraryPath(str);
    QString strl = QString("(%1): %2").arg(a.libraryPaths().count()).arg(a.libraryPaths().join(";"));

    The strl variable is passed to MainWindow to display what paths are checked, here is the strl value:
    (2): C:/slican/plugins;C:/slican

    And when I try to connect to DB it still says that driver was not loaded. Test machine is the newly created virtual machine with windows 10 on board. Do I need to copy any dll somewhere to the windows directory or something?
    Can anyone help?

    Thanks & Regards
    Przemek



  • "qsqlmysql.dll" depends on "libmysql.dll", which is not distributed with Qt due to licensing issues. Maybe that's what you're missing. You should have it in your exe's directory.


  • Lifetime Qt Champion

    Hi,

    To add to @Leonardo you also have the windeployqt tool that might help you get your dependencies right.



  • @Leonardo Thanks, that helped.
    @SGaist Thanks, I'll check that.

    Regards,
    Przemek


Log in to reply
 

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