MySQL Driver Problems (Solved it)



  • Hello, I've been trying to install the mySQL driver (Windows 7) and its been a headache. It was so easy to install in Ubuntu :(

    Anyways, after using this "guide":http://www.pikopong.com/blog/2010/04/11/how-to-enable-mysql-support-in-qt-sdk-for-windows/

    The commands for the QT Command Propmt "worked" but when I test the drivers in my application I only get
    @int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);
    qDebug() << QSqlDatabase::drivers();
    return a.exec();
    }@

    @<"QSQLITE", "QODBC3", "QODBC">@

    Here are my commands:
    @Setting up a MinGW/Qt only environment...
    -- QTDIR set to C:\Qt\2010.05\qt
    -- PATH set to C:\Qt\2010.05\qt\bin
    -- Adding C:\Qt\2010.05\bin to PATH
    -- Adding C:\Windows\System32 to PATH
    -- QMAKESPEC set to win32-g++

    C:\Windows\system32>set mySQLDIR=c:\mySQL

    C:\Windows\system32>cd %QTDIR%\src\plugins\sqldrivers\mysql

    C:\Qt\2010.05\qt\src\plugins\sqldrivers\mysql>qmake "INCLUDEPATH+=%mySQLDIR%\inc
    lude" "LIBS+=%mySQLDIR%\lib\libmysql.lib" -o Makefile mysql.pro
    WARNING: (internal):1: Unescaped backslashes are deprecated.
    WARNING: (internal):1: Unescaped backslashes are deprecated.
    WARNING: (internal):1: Unescaped backslashes are deprecated.

    C:\Qt\2010.05\qt\src\plugins\sqldrivers\mysql>mingw32-make
    mingw32-make -f Makefile.Debug all
    mingw32-make[1]: Entering directory C:/Qt/2010.05/qt/src/plugins/sqldrivers/mys ql' g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel oc -mthreads -Wl -shared -Wl,--out-implib,c:\Qt\2010.05\qt\plugins\sqldrivers\li bqsqlmysqld4.a -o ..\..\..\..\plugins\sqldrivers\qsqlmysqld4.dll tmp/obj/debug_s hared/main.o tmp/obj/debug_shared/qsql_mysql.o tmp/obj/debug_shared/moc_qsql_mys ql.o -L"c:\Qt\2010.05\qt\lib" -L"c:\Qt\2010.05\qt\lib" tmp\obj\debug_shared\qsq lmysqld_resource_res.o c:\mySQL\lib\libmysql.lib -lQtSqld4 -lQtCored4 Creating library file: c:\Qt\2010.05\qt\plugins\sqldrivers\libqsqlmysqld4.a mingw32-make[1]: Leaving directoryC:/Qt/2010.05/qt/src/plugins/sqldrivers/mysq
    l'
    mingw32-make -f Makefile.Release all
    mingw32-make[1]: Entering directory `C:/Qt/2010.05/qt/src/plugins/sqldrivers/mys
    ql'
    g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT
    -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_NO_DEBUG -DQT_PLUGIN
    -DQT_SQL_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"........\include\QtCore" -
    I"........\include\QtSql" -I"........\include" -I"c:\mySQL\include" -I"..
    ......\include\ActiveQt" -I"tmp\moc\release_shared" -I"........\mkspecs\win
    32-g++" -o tmp\obj\release_shared\main.o main.cpp
    C:\Qt\2010.05\qt\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_CAST_TO_AS
    CII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT
    CORE_LIB -DQT_THREAD_SUPPORT -I"........\include\QtCore" -I"........\incl
    ude\QtSql" -I"........\include" -I"c:\mySQL\include" -I"........\include\A
    ctiveQt" -I"tmp\moc\release_shared" -I"........\mkspecs\win32-g++" -D__GNUC
    _
    -DWIN32 ......\sql\drivers\mysql\qsql_mysql.cpp -o tmp\moc\release_shared\qsq
    l_mysql.moc
    g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT
    -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_NO_DEBUG -DQT_PLUGIN
    -DQT_SQL_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"........\include\QtCore" -
    I"........\include\QtSql" -I"........\include" -I"c:\mySQL\include" -I"..
    ......\include\ActiveQt" -I"tmp\moc\release_shared" -I"........\mkspecs\win
    32-g++" -o tmp\obj\release_shared\qsql_mysql.o ......\sql\drivers\mysql\qsql_m
    ysql.cpp
    C:\Qt\2010.05\qt\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_CAST_TO_AS
    CII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT
    CORE_LIB -DQT_THREAD_SUPPORT -I"........\include\QtCore" -I"........\incl
    ude\QtSql" -I"........\include" -I"c:\mySQL\include" -I"........\include\A
    ctiveQt" -I"tmp\moc\release_shared" -I"........\mkspecs\win32-g++" -D__GNUC
    _
    -DWIN32 ......\sql\drivers\mysql\qsql_mysql.h -o tmp\moc\release_shared\moc_q
    sql_mysql.cpp
    g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT
    -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_NO_DEBUG -DQT_PLUGIN
    -DQT_SQL_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"........\include\QtCore" -
    I"........\include\QtSql" -I"........\include" -I"c:\mySQL\include" -I"..
    ......\include\ActiveQt" -I"tmp\moc\release_shared" -I"........\mkspecs\win
    32-g++" -o tmp\obj\release_shared\moc_qsql_mysql.o tmp\moc\release_shared\moc_qs
    ql_mysql.cpp
    windres -i qsqlmysql_resource.rc -o tmp\obj\release_shared\qsqlmysql_resource_re
    s.o --include-dir=. -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_CAST_TO_ASCII -DQT_
    NO_CAST_FROM_ASCII -DQT_DLL -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB
    -DQT_THREAD_SUPPORT
    g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel
    oc -Wl,-s -mthreads -Wl -shared -Wl,--out-implib,c:\Qt\2010.05\qt\plugins\sqldri
    vers\libqsqlmysql4.a -o ........\plugins\sqldrivers\qsqlmysql4.dll tmp/obj/re
    lease_shared/main.o tmp/obj/release_shared/qsql_mysql.o tmp/obj/release_shared/m
    oc_qsql_mysql.o -L"c:\Qt\2010.05\qt\lib" -L"c:\Qt\2010.05\qt\lib" tmp\obj\relea
    se_shared\qsqlmysql_resource_res.o c:\mySQL\lib\libmysql.lib -lQtSql4 -lQtCore4

    Creating library file: c:\Qt\2010.05\qt\plugins\sqldrivers\libqsqlmysql4.a
    mingw32-make[1]: Leaving directory `C:/Qt/2010.05/qt/src/plugins/sqldrivers/mysq
    l'

    C:\Qt\2010.05\qt\src\plugins\sqldrivers\mysql>@

    Thanks in advanced, Dukaim



  • Solved it my copying the libmysql.dll from the mySQL directory to C:\Windows if anyone is having the same problem.

    Thanks tho. :D



  • That sounds like a terrible idea. Just copy the dll in the very directory of the application you're building, or put it in a safe place in PATH (like the qt/bin subdir of the SDK).


Log in to reply
 

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