Results 1 to 5 of 5

Thread: Trouble installing mysql driver

  1. #1
    Join Date
    Aug 2011
    Posts
    42
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Trouble installing mysql driver

    I have tried numerous ways, based on the posts i've read on this forum, but I still have problems with installing it.

    I have tried
    configure -plugin-sql-mysql

    C:\Qt\2009.01\qt> cd src\plugins\sqldrivers\mysql
    C:\Qt\2009.01\qt\src\plugins\sqldrivers\mysql> set MYSQL_PATH=c:mysql
    C:\Qt\2009.01\qt\src\plugins\sqldrivers\mysql> reimp -d %MYSQL_PATH%\lib\opt\libmysql.lib
    C:\Qt\2009.01\qt\src\plugins\sqldrivers\mysql> dlltool -k --input-def LIBMYSQL.def --dllname libmysql.dll --output-lib libmysql.a
    C:\Qt\2009.01\qt\src\plugins\sqldrivers\mysql> qmake "INCLUDEPATH+=%MYSQL_PATH%include" "LIBS+=-L. -lmysql" mysql.pro
    nmake

    It ran fine & generated qsqlmysql4.lib, qsqlmysql4.dll files. I've also put them in the library path & in the qt bin folder(just to be sure.) But the msql is still isnt getting picked up

    #include <QtSql/QSqlDatabase>
    #include <QtSql/QSqlError>
    #include <QtSql/QSqlQuery>
    #include <QtSql/QMYSQLDriver>
    #include <QtSql/qsql_mysql.h>
    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    QString s( QSqlDatabase::drivers().join( "." )) ;
    qDebug()<< s;
    }

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE
    "QSQLITE"

    What am i doing wrong here

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Trouble installing mysql driver

    What am i doing wrong here
    If had a dollar/pound/złoty for every time someone followed an incomplete or incorrect "tutorial" thinking they were saving themselves time... A whole bunch of the stuff you have done was completely unnecessary, e.g. the reimp and dlltool stuff is for MinGW when you clearly are using Microsoft's tools. However, you missed the obvious and necessary:
    Qt Code:
    1. nmake install
    To copy to clipboard, switch view to plain text mode 
    after building the plugin.

  3. #3
    Join Date
    Aug 2011
    Posts
    42
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Trouble installing mysql driver

    Oh. Would i just have to run the following two commands?

    configure -plugin-sql-mysql
    nmake install

  4. #4
    Join Date
    Aug 2011
    Posts
    42
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Trouble installing mysql driver

    Its still not working. the nmake install ran without any problems, but the mysql plugin is isnt getting picked up.

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE
    "QSQLITE"

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Trouble installing mysql driver

    It is all in the documentation. You have two different ways to do it:
    1. Building the Drivers Using Configure. You build and install the MySQL plugin as you build and install the Qt library itself, OR
    2. How to Build the QMYSQL Plugin on Windows. You build and install the plugin on its own after you have built and installed Qt.

    Pick one.

    For option 1: You use the Qt configure script to tell Qt to build the plugin, then build Qt, install Qt, done. Here is an example. It is not exactly what you type. You have to adapt it to your system
    Qt Code:
    1. cd {qt source dir}
    2. configure {... other options ...} -Ic:/mysql/include -Lc:/mysql/lib -lmysql -plugin-sql-mysql
    3. nmake
    4. nmake install
    To copy to clipboard, switch view to plain text mode 

    For option 2: You move to the plugin source directory, run qmake with some options, make, install, done. Here is an example. It is not exactly what you type. You have to adapt it to your system
    Qt Code:
    1. cd %QTDIR%\src\plugins\sqldrivers\mysql
    2. qmake "INCLUDEPATH+=C:\MySQL\include" "LIBS+=C:\MYSQL\MySQL Server <version>\lib\opt\libmysql.lib" mysql.pro
    3. nmake
    4. nmake install
    To copy to clipboard, switch view to plain text mode 
    You might recognise that as being exactly what is in the manual with the install step added.

    If you already have Qt and MySql installed the total time for Option 2 is less than ten minutes.
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

Similar Threads

  1. installing QPSQL DRIVER windows 7
    By esta in forum Qt Programming
    Replies: 0
    Last Post: 15th March 2012, 10:16
  2. Mysql driver installing problem
    By xtra in forum Newbie
    Replies: 4
    Last Post: 6th March 2012, 13:24
  3. source code for odbc driver or MySql driver in arm-embedded-linux
    By sattu in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 24th January 2011, 11:11
  4. I need MySQL driver for Qt 4.6, WindowsXP(32), MySQL 5.1
    By User_3 in forum Installation and Deployment
    Replies: 7
    Last Post: 15th October 2010, 16:19
  5. installing OCI driver
    By dilidpan in forum Qt Programming
    Replies: 8
    Last Post: 15th June 2009, 12:44

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.