Results 1 to 7 of 7

Thread: MySql and QtPlugin

  1. #1
    Join Date
    Jan 2007
    Posts
    68
    Thanks
    9
    Thanked 8 Times in 8 Posts

    Default MySql and QtPlugin

    Hello,

    Today i've tried to use my mysql db, instead of the sqlite db i used so far.

    When i tried to connect to the new db, i came across the QSqlDatabase: QMYSQL driver not loaded error.

    To create the missing mysql driver i used following instruction:

    1.
    cd %QTDIR%\src\plugins\sqldrivers\mysql
    qmake -o Makefile "INCLUDEPATH+=C:\MYSQL\INCLUDE" "LIBS+=C:\MYSQL\LIB\OPT\LIBMYSQL.LIB" mysql.pro
    nmake
    2.
    Copy the libmysql.dll file from the MySQL installation's bin directory to a directory in %PATH% (e.g. %QTDIR%/bin). (--> copied to it to C:\Program Files\qt4\bin)
    everything worked fine so far, next i insertet

    #include <QtPlugin>
    Q_IMPORT_PLUGIN(qsqlmysql)

    in my code and

    QTPLUGIN += qsqlmysql

    in my *.pro file, as described here: http://doc.trolltech.com/4.1/plugins-howto.html

    while i try to compile the project i get the following errormessage: undefined reference to `qt_plugin_instance_qsqlmysql()

    I know adding LIBS += ???.file could help but what files or directories do i have to add ??? Tired already lots of files without results.

    Hope someone knows a solution...

    PS: using QT::4:2:2 and Visual Studio 2003
    Last edited by jacek; 13th May 2007 at 20:37. Reason: changed [code] to [quote]

  2. #2
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: MySql and QtPlugin

    Quote Originally Posted by darksaga View Post
    Hello,

    Today i've tried to use my mysql db, instead of the sqlite db i used so far.
    PS: using QT::4:2:2 and Visual Studio 2003

    can you see the mysql driver on

    %QDIR%\demos\sqlbrowser\release ?

    i put only QT += sql on my pro file and all run on qt4.3 beta

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: MySql and QtPlugin

    Do you have a static installation of Qt? If not, you don't need Q_IMPORT_PLUGIN or the changes to the project file, just follow the article in our wiki about enabling MySQL support for Qt.

  4. #4
    Join Date
    Jan 2007
    Posts
    68
    Thanks
    9
    Thanked 8 Times in 8 Posts

    Default Re: MySql and QtPlugin

    Quote Originally Posted by patrik08 View Post
    can you see the mysql driver on

    %QDIR%\demos\sqlbrowser\release ?

    i put only QT += sql on my pro file and all run on qt4.3 beta
    it's just the QODBC & QSQLITE driver that the driver combobox shows if i run the demo.

    i used the QT += sql flag from the start in my project....

    i know there is an option that compiles the mysql driver during your first "installation (compilation)".

    maybe you used that flag, i didn't.

  5. #5
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: MySql and QtPlugin

    Quote Originally Posted by darksaga View Post
    it's just the QODBC & QSQLITE driver that the driver combobox shows if i run the demo.
    i used the QT += sql flag from the start in my project....
    .
    You qt4 installation dont have mysql ... otherwise on %QDIR%\demos\sqlbrowser\release textfield driver mysql is visible!

    Move your visual compiler to Trash if visual studio is to hard to handle .. and begin on mingw compiler http://www.mingw.org/ ....

    After you have get compiler.... and minimal sys.. (like a linux console emulator you can compile all)
    cd dir libmysql.lib
    Qt Code:
    1. reimp -d libmysql.lib
    2. dlltool -k --input-def libmysql.def --dllname libmysql.dll --output-lib libmysql.a
    3. dlltool --input-def libmysql.def --dllname libmysql.dll --output-lib c:\MingW\lib\libmysql.a
    To copy to clipboard, switch view to plain text mode 

    now put mysql include to mingw include dir and run..

    version qt4.3 ...
    Qt Code:
    1. configure -qt-sql-mysql -qt-sql-odbc -qt-sql-sqlite -qt-gif -qt-tif -qt-libpng -qt-libjpeg
    2. make
    To copy to clipboard, switch view to plain text mode 

    cd to %QDIR%\demos\sqlbrowser\release and you can see mysql driver work...
    Visual studio have to much option and button ... and confusion ...
    I have all two compiler on two pc ... but 90% i work only on mingw ... is more easy...

  6. #6
    Join Date
    Jan 2007
    Posts
    68
    Thanks
    9
    Thanked 8 Times in 8 Posts

    Default Re: MySql and QtPlugin

    Quote Originally Posted by wysota View Post
    Do you have a static installation of Qt? If not, you don't need Q_IMPORT_PLUGIN or the changes to the project file, just follow the article in our wiki about enabling MySQL support for Qt.
    have a shared installation, so a solution using q_import_plugin is obsolete

    so I tried the followin steps:

    1.)
    - followed the article the wiki about enabling MySQL support link

    did exactly as in the description:

    - compiles fine, qsqlmysql.dll is created, qsqlmysql.dll and libqsqlmysql.a files are in the %QTDIR%/plugins/ directory
    - copied libmysql.dll file from the MySQL installation's bin directory to %QTDIR%/bin

    result --> QSqlDatabase: QMYSQL driver not loaded

    2.)
    after that i decided to install & compile everything from scratch:
    - installed new mysql-5.0.41-win32 server
    - downloaded qt-win-opensource-src-4.2.3.zip & acs-4.2.3-patch1.zip (visual studio patch)

    then proceeded exactly as in the "Qt4 with Visual Studio" tutorial link

    following qt compile configuration
    Qt Code:
    1. qconfigure msvc.net -prefix C:\qt4shared -qt-sql-mysql -I C:\mysql\include -L C:\mysql\lib\opt
    To copy to clipboard, switch view to plain text mode 

    during compilation an error occurs while creating the qtsqld4.dll with the following error:



    if i do not use the -qt-sql-mysql flag everything finishes fine, but i do not have mysql support.

    3.)
    tried another attempt with a fresh compiled qt (without -qt-sql-mysql flag) and proceeded as in the wiki about enabling MySQL support link
    but the result still is the same --> QSqlDatabase: QMYSQL driver not loaded

    following questions arise:

    - is the mysql-5.0.41-win32 server not compatible with qt 4.2.x ?

    - is the acs-4.2.3-patch1.zip (visual studio patch) flawed at some script?

    the patch modifies the src/sql/sql.pro file:

    original:
    Qt Code:
    1. TARGET = QtSql
    2. QPRO_PWD = $$PWD
    3. QT = core
    4. DEFINES += QT_BUILD_SQL_LIB
    5. win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x62000000
    6.  
    7. include(../qbase.pri)
    8.  
    9. DEFINES += QT_NO_CAST_FROM_ASCII
    10. PRECOMPILED_HEADER = ../corelib/global/qt_pch.h
    11. SQL_P = sql
    12.  
    13. include(kernel/kernel.pri)
    14. include(drivers/drivers.pri)
    15. include(models/models.pri)
    To copy to clipboard, switch view to plain text mode 

    modified:
    Qt Code:
    1. TARGET = QtSql
    2. QPRO_PWD = $$PWD
    3. QT = core
    4. DEFINES += QT_BUILD_SQL_LIB
    5. win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x62000000
    6. win32-borland:QMAKE_LFLAGS += /b:0x62000000
    7.  
    8. include(../qbase.pri)
    9.  
    10. DEFINES += QT_NO_CAST_FROM_ASCII
    11. PRECOMPILED_HEADER = ../corelib/global/qt_pch.h
    12. SQL_P = sql
    13.  
    14. include(kernel/kernel.pri)
    15. include(drivers/drivers.pri)
    16. include(models/models.pri)
    To copy to clipboard, switch view to plain text mode 

    maybe somebody can figure out more ???

    Quote Originally Posted by patrik08
    Visual studio have to much option and button ... and confusion ...
    I have all two compiler on two pc ... but 90% i work only on mingw ... is more easy...
    I don't think its that bad, an I'm used to it.

    And until now I had no prob using QT in Visual studio...

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: MySql and QtPlugin

    Quote Originally Posted by darksaga View Post
    have a shared installation, so a solution using q_import_plugin is obsolete

    so I tried the followin steps:

    1.)
    - followed the article the wiki about enabling MySQL support link

    did exactly as in the description:

    - compiles fine, qsqlmysql.dll is created, qsqlmysql.dll and libqsqlmysql.a files are in the %QTDIR%/plugins/ directory
    - copied libmysql.dll file from the MySQL installation's bin directory to %QTDIR%/bin

    result --> QSqlDatabase: QMYSQL driver not loaded
    Did you empty the plugin cache?

    - is the mysql-5.0.41-win32 server not compatible with qt 4.2.x ?
    It should work fine provided that it is built with the same compiler. AFAIK, MinGW dlls won't work with MSVC dlls. Was this MySQL compiled with MSVC?

    - is the acs-4.2.3-patch1.zip (visual studio patch) flawed at some script?
    The script doesn't have anything to do with this.

    maybe somebody can figure out more ???
    I think it's fine. The linker just can't find a symbol needed. It's definitely a compiler issue, so please try using a different compiler in one of the two places (Qt or MySQL).

Similar Threads

  1. Statically compiled Qt 4.1.4 and mySql
    By Djony in forum Installation and Deployment
    Replies: 1
    Last Post: 26th January 2007, 07:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.