MySQL 5.6 driver available, yet not loaded?



  • EDIT:

    I'd like to note my environment has changed. I have changed from Qt5.1 using MinGW to Qt5.2 for VS2012 32-bit and using VS2012 compiler for 32-bit from VS 2012 Express. I am also using MySQL Server 5.6 32-bit. Qt5.2 comes with precompiled QMYSQL drivers, and even these do not work. So I'm still at a loss.

    ORIGINAL:

    If this is in the wrong area, I am sorry. It seemed like a fitting location to me.

    I did a search for topics similar and found quite a few related discussions, however the ones I tried were unsuccessful at solving my issue. I am running Windows 8 64-bit, using Qt Creator 2.8.1 based on Qt 5.1.1 with MinGW 4.8 32-bit.

    What happened? I'm not entirely sure, but when I debug it, I noticed this
    @>=library-loaded,id="C:\\Qt\\5.1.1\\mingw48_32\\plugins\\sqldrivers\\qsqlmysql.dll",target-name="C:\\Qt\\5.1.1\\mingw48_32\\plugins\\sqldrivers\\qsqlmysql.dll",host-name="C:\\Qt\\5.1.1\\mingw48_32\\plugins\\sqldrivers\\qsqlmysql.dll",symbols-loaded="0",thread-group="i1"
    Library C:\Qt\5.1.1\mingw48_32\plugins\sqldrivers\qsqlmysql.dll loaded

    =library-unloaded,id="C:\\Qt\\5.1.1\\mingw48_32\\plugins\\sqldrivers\\qsqlmysql.dll",target-name="C:\\Qt\\5.1.1\\mingw48_32\\plugins\\sqldrivers\\qsqlmysql.dll",host-name="C:\\Qt\\5.1.1\\mingw48_32\\plugins\\sqldrivers\\qsqlmysql.dll",thread-group="i1"
    Library C:\Qt\5.1.1\mingw48_32\plugins\sqldrivers\qsqlmysql.dll unloaded
    =library-loaded,id="C:\\Qt\\5.1.1\\mingw48_32\\plugins\\sqldrivers\\qsqlmysqld.dll",target-name="C:\\Qt\\5.1.1\\mingw48_32\\plugins\\sqldrivers\\qsqlmysqld.dll",host-name="C:\\Qt\\5.1.1\\mingw48_32\\plugins\\sqldrivers\\qsqlmysqld.dll",symbols-loaded="0",thread-group="i1"
    Library C:\Qt\5.1.1\mingw48_32\plugins\sqldrivers\qsqlmysqld.dll loaded
    =library-unloaded,id="C:\\Qt\\5.1.1\\mingw48_32\\plugins\\sqldrivers\\qsqlmysqld.dll",target-name="C:\\Qt\\5.1.1\\mingw48_32\\plugins\\sqldrivers\\qsqlmysqld.dll",host-name="C:\\Qt\\5.1.1\\mingw48_32\\plugins\\sqldrivers\\qsqlmysqld.dll",thread-group="i1"
    Library C:\Qt\5.1.1\mingw48_32\plugins\sqldrivers\qsqlmysqld.dll unloaded@

    For some reason they are being unloaded? What causes this and how do I correct it so I can connect to my databases?

    If anything else is needed (system/software information), let me know and I'll make it available.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Do you have MySQL installed ? Is the path to the MySQL dlls in your PATH environment variable ?
    You can use Dependency Walker on your qsqlmysql.dll to see whether all dependencies can be found



  • The dependencies that aren't located when using dependency walker on qsqlmysql.dll are:

    • qt5core.dll
    • qt5sql.dll
    • libgcc_s_dw2-1.dll; and
    • libstdc++-6.dll

    To me this seems normal, as they would be loaded into the project with this dll as well so it would be access to them, and would not pose an issue.

    Unless I've completely confused how this works, in which case please fill me in.


  • Lifetime Qt Champion

    So it does find the MySQL dlls ?

    If so, you need to add some debugging statement in your code to see what error does QSqlDatabase return and also double check that PATH in your run table does contain the path to the MySQL dlls



  • When I run dependency walker on my exe, all dll's required are present. In my PATH var, all required dll's have paths pointing to them. I'm confused and frustrated and have NO clue what to do or how to get it working.


  • Lifetime Qt Champion

    Do you test whether your database opening is successful ? If so do you print a warning with QSqlDatabase::lastError() content ?



  • Yes I do.

    @
    bool hasMysql = ((db->drivers().indexOf("QMYSQL") > -1) ? true:false);

    if (hasMysql) {
        new QListWidgetItem(timestamp() + QString("MySQL driver located"), ui->messageWindow);
        db->addDatabase("QMYSQL");
        db->setHostName("localhost");
        db->setDatabaseName("psadatacentral");
        db->setUserName("guest");
        db->setPassword("public");
        if (!db->open())
            conReply = db->lastError().text();
        else
            conReply = tr("Successfully connected to database `") + db->databaseName() + tr("`");
    } else {
        conReply = tr("MySQL driver unavailable");
    }
    

    @

    And the output of that is

    @
    MySQL driver located
    Driver not loaded Driver not loaded
    @


  • Lifetime Qt Champion

    Maybe a silly question but, did you install a 32bit MySQL ?



  • I rechecked to make sure and yes. I have 32bit MySQL server 5.6 running, 32bit qt-creator, 32bit drivers (debug and release builds).



  • Try setting the QT_DEBUG_PLUGINS environment variable to 1 when you run your application. It will give you a lot of debug info that can be useful to debug why plugins don't load.



  • I did that aswell and it loads qsqlmysqld.dll if it's a debug build, and loads qsqlmysql.dll if it's a release build.


  • Lifetime Qt Champion

    Did you check the PATH variable in the Run pane of your project to see whether the path the MySQL was also there ?



  • It has the path to mysql utilities. As far as I'm aware, it never had anything other path in it regarding mysql, or to my knowledge needed any other.

    ALSO: As a note, the guide I followed to make my drivers, when running the qmake, while appending to LIBS

    @"LIBS+=%mysql%\lib\libmysql.lib"@
    was used opposed to
    @"LIBS+=-L%mysql%\lib\libmysql.lib"@
    because the site I used didn't have it present. When I found out (just recently), I tried to rebuild them, and I get several undefined reference errors ("visible here":http://pastebin.com/9FtYi9dh)



  • I hate to bump this up or anything, and I do appreciate the help. Problem is I'm on a time limit and I really need to solve this issue, so If anyone has anything to contribute, please let me know! I'm still stuck on this, and have been for 2 two weeks.

    So please, anything will help I'm sure!

    EDIT: I'd like to note my environment has changed. I have changed from Qt5.1 using MinGW to Qt5.2 for VS2012 32-bit and using VS2012 compiler for 32-bit from VS 2012 Express. I am also using MySQL Server 5.6 32-bit. Qt5.2 comes with precompiled QMYSQL drivers, and even these do not work. So I'm still at a loss.


Log in to reply
 

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