Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Qt 4.8 and MySQL plugin error
Forum Updated to NodeBB v4.3 + New Features

Qt 4.8 and MySQL plugin error

Scheduled Pinned Locked Moved Installation and Deployment
3 Posts 2 Posters 3.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Leeeeeeelo
    wrote on 4 Apr 2012, 22:31 last edited by
    #1

    Hello everyone,

    I am new to Qt, I installed the 1.2 SDK version not a long time ago. I am trying to establish a connection with MySQL but in vain. I have tried lots of tutorials, this is driving me crazy since few days !

    • I have Windows 7 Home Premium 64 bits.
    • I installed the Qt SDK from an offline installer that I downloaded from the Nokia website, entitled : Qt_SDK_Win_offline_v1_2_en.exe ( I am using MSVC 2010 and not MinGW ), and the directory is C:\QtSDK
    • I installed MySQL Community Edition 64 bits from a MSI Installer that I downloaded from the MySQL website, entitled : mysql-5.5.22-winx64.msi

    I read somewhere that the lib and include folders of the 64 bits version of MySQL cannot be used for the plugin so I installed mysql-5.5.22-win32.msi on a virtual machine and copied the lib and include folders to C:\MySQL.

    Afterwards, I successfully executed the following commands :

    @cd C:\QtSDK\QtSources\4.8.0\src\plugins\sqldrivers\mysql
    qmake 'INCLUDEPATH+=c:/MySQL/include" "LIBS+=-Lc:/MySQL/lib" mysql.pro
    nmake debug
    nmake release@

    I then copied the files qsqlmysql4.dll , qsqlmysql4.lib , qsqlmysqld4.dll and qsqlmysqld4.lib to C:\QtSDK\Desktop\Qt\4.8.0\msvc2010\plugins\sqldrivers.

    In addition I copied libmysql.lib ( from the include folder of MySQL ) to the following folders:

    • C:\QtSDK\Desktop\Qt\4.8.0\msvc2010\plugins\sqldrivers
    • C:\QtSDK\QtSources\4.8.0\src\plugins\sqldrivers\mysql\release
    • C:\QtSDK\QtSources\4.8.0\src\plugins\sqldrivers\mysql\debug
    • The debug folder of my app
    • The release folder of my app

    I even added the path of the file libmysql.lib ( which is C:\MySQL\lib ) to the PATH environment variable of windows.

    I also tried to clear the cache by deleting the following folders in the registry :

    • HKEY_CURRENT_USER\Software\Trolltech\OrganizationDefaults\Qt Plugin Cache 4.x.false
    • HKEY_CURRENT_USER\Software\Trolltech\OrganizationDefaults\Qt Plugin Cache 4.x.debug

    My application consists of one cpp file that contains the following code :

    @# include <QApplication>

    include <QDebug>

    include <Qtsql/QSqlDatabase>

    include <QStringList>

    int main ( int argc , char * argv [] ) {

    QCoreApplication a(argc, argv);
    qDebug() << QSqlDatabase::drivers();
    return a.exec&#40;&#41;;
    

    }@

    I am getting the following errors :

    @BusinessLogic.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: static class QStringList __cdecl QSqlDatabase::drivers(void)" (_imp?drivers@QSqlDatabase@@SA?AVQStringList@@XZ) referenced in function _main

    debug\ETE.exe:-1: error: LNK1120: 1 unresolved externals
    @

    I will really appreciate any help !!

    Thank you in advance !!

    Leeeeeeelo.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JonasAH
      wrote on 5 Apr 2012, 19:55 last edited by
      #2

      You need to add the QtSql module in your Qt project file (.pro):

      @ QT += sql@

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Leeeeeeelo
        wrote on 5 Apr 2012, 20:21 last edited by
        #3

        Hello JonasAH !

        Thank you for your prompt reply, but I actually forgot to mention that I already added this model in the .pro file, in vain :/

        Any other suggestions ??

        1 Reply Last reply
        0

        1/3

        4 Apr 2012, 22:31

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved