Important: Please read the Qt Code of Conduct -

Qt 4.8.5 + MySQL + Windows

  • Hi everybody,

    I'm sorry to post a so simple question but I'm new to MySQL and compiling stuff.

    So I follow "these instructions": to build the QMYSQL plugin on Windows.

    I adapt the instruction like this (for my setup) :

    • set QMAKESPEC=C:\Qt\4.8.5\mkspecs\win32-msvc2010
    • cd C:\Qt\4.8.5\src\plugins\sqldrivers\mysql
    • c:/qt/4.8.5/qmake/qmake "INCLUDEPATH+=C:/Program Files/MySQL/MySQL Server 5.6/include" "LIBS+=C:/Program Files/MySQL/MySQL Server 5.6/lib/libmysql.lib"

    until now I have no problem...

    When I call nmake like this :

    • "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\nmake.exe"

    I got this error message :

    Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
    Copyright (C) Microsoft Corporation. Tous droits réservés.

    "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\nmake.exe" -f Makefile.Release

    Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
    Copyright (C) Microsoft Corporation. Tous droits réservés.

    C:\iwmake\build_vs2010_opensource_________________PADDING_________________\bin\moc.exe -DUNICODE -DWIN32
    -DWIN32 ......\sql\drivers\mysql\qsql_mysql.cpp -o release\qsql_mysql.moc
    The system cannot find the path specified.
    NMAKE : fatal error U1077: 'C:\iwmake\build_vs2010_opensource_________________PADDING_________________\bin\moc.exe' : code retour '0x1'
    NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\nmake.exe"' : code retour '0x2'

    I'm sorry for some part of the message in french.

    In fact, I do not understand what is all the "c:\iwmake\build_vs2010_opensource_________________PADDING_________ ..."
    I have no folder named c:\iwmake

    It's my first time using qmake & nmake.

    I will appreciate any inputs. Thanks in advance!

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    First thing to do install reinstall MySQL in a path without space or use the old 8.3 format to give the library path then try again.

    You can also find numerous posts about this subject that might help you on this forum

    Hope it helps

  • Thanks for the reply,

    I did what you proposed (removed & reinstalled MySQL with 8.3 format name) but I get the same error.

    I look for a post to help me but I found nothing helpful. May be it's my lack of knowledge that prevent me to found something.

    Any suggestion from this...

    If anyone understand the meaning of the previous error message, that will be really appreciated.

  • Hi, I suggest to follow this tutorial "Qt5 MYSQL Win7":

  • Lifetime Qt Champion

    I didn't suggest to install it using 8.3 names, just in a path without spaces. If you wanted to keep your original installation, you would have need to use the 8.3 notations.

    Where do you have your MySQL installed now ?

  • I follow the steps in this tutorial ("Create MySQL driver for Qt on Windows": and I adapt some of it for my situation :

    • Qt 4.8.5

    • Microsoft Visual Studio 2010

    • I also installed MySQL 5.5 32bits

    • then I followed this steps : run the following commands from the Qt Command Prompt

    1. set mysql=C:\PROGRA~2\MySQL\MYSQLS~1.5

    2. cd C:\Qt\4.8.5\src\plugins\sqldrivers\mysql

    3. qmake "INCLUDEPATH+=%mysql%\include" "LIBS+=%mysql%\lib\libmysql.lib" -o Makefile

    4. "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\nmake.exe"

    5. qmake "INCLUDEPATH+=%mysql%\include" "LIBS+=%mysql%\lib\libmysql.lib" -o Makefile "CONFIG+=release"

    6. "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\nmake.exe"

    At this point, everything seem to go well. Thanks to you both.

    From now I copy the following to C:\Qt\4.8.5\plugins\sqldrivers

    • qsqlmysql4.dll + qsqlmysql4.lib (from C:\Qt\4.8.5\src\plugins\sqldrivers\mysql\release)

    • qsqlmysqld4.dll + qsqlmysqld4.lib (from C:\Qt\4.8.5\src\plugins\sqldrivers\mysql\debug)

    Also copying

    C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib\libmysql.dll



    From this, I was sure it should work!

    But I got a strange behavior, when I run this command :

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL", "my_sql_db");

    I got this output :


    'Database01.exe' : Chargé 'C:\Qt\4.8.5\plugins\sqldrivers\qsqlmysqld4.dll', Les symboles ont été chargés.

    'Database01.exe' : Déchargé 'C:\Qt\4.8.5\plugins\sqldrivers\qsqlmysqld4.dll'

    QSqlDatabase: QMYSQL driver not loaded

    QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC QPSQL7 QPSQL


    I'm sorry for the french part again (Chargé mean loaded) and (Déchargé mean unloaded).

    Now, do somebody know why the driver seem to load and unload immediately after?

    Thanks again!

  • Lifetime Qt Champion

    Did you check what lastError() returns ?

  • I didn't check, thanks.

    The return is

    driverError = "Driver not loaded"
    databaseError = "Driver not loaded"
    errorType = ConnectionError
    errorNumber = -1

    This is interesting, but it doesn't explain why the driver seems to load and right after it is unloaded.

    Thanks for your help...

  • copy the libmysql.dll to the application directory.


  • Thanks for this input.

    I copied this DLL everywhere just to be sure (qt/bin, windows/system32, in the application directory, ...)

    And I obtain the same result... :-(

  • Did you copy libmysqld.dll for debug build, too?

  • You found something here. I did not copy the debug DLL. But I can't find it on the MySQL installation.

    I found the release version on the MySQL/lib folder. And if I compile and run in release, I still got the same problem.

Log in to reply