Results 1 to 2 of 2

Thread: using mysql plugin

  1. #1
    Join Date
    Jul 2011
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default using mysql plugin

    Hello:

    I have successfully built the mysql plugin for QT. The build process resulted in the following 4 files:

    qsqlmysql4.dll
    qsqlmysql4.lib
    qsqlmysqld4.dll
    qsqlmysqld4.lib.

    I copied the above files to the plugins directory of QT, and the .dll's to C:\windows\system32
    Then I wrote sample code to test
    Qt Code:
    1. #include <QApplication>
    2. #include <QtSql>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QCoreApplication a(argc, argv);
    7. qDebug() << QSqlDatabase::drivers();
    8. return a.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 


    The code compiles, links and runs fine but i get no output.
    According to http://www.pikopong.com/blog/2010/04...k-for-windows/

    The above code should output :
    Qt Code:
    1. ("QSQLITE", "QMYSQL3", "QMYSQL", "QODBC3", "QODBC")
    To copy to clipboard, switch view to plain text mode 

    What am I doing wrong?

  2. #2
    Join Date
    Oct 2011
    Location
    Russia, Ivanovo
    Posts
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: using mysql plugin

    Step by step compiling is (sorry for automatic translation):
    In windows
    After installing QT SDK (2010.05) or Nokia QT SDK Kit automatically installed some drivers to access databases, unfortunately the MySQL driver in the list is not included. Recognize that QT can not find the necessary driver is simple.

    //---- Example of connection to the database ----
    QSqlDatabase db = QSqlDatabase:: addDatabase ("QMYSQL", "MyConnection");
    db.setHostName ("serverName");
    db.setDatabaseName ("dbName");
    db.setPort (3306);
    db.setUserName ("login");
    db.setPassword ("psw");
    db.open ();
    qDebug () <<db.lastError ();
    //------------------------------

    In this case, the console application, I get the following messages:
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC
    QSqlError (-1, "Driver not loaded", "Driver not loaded")

    Recommendations installation
    To address the need libraries MySQL. Required libraries are available when you install MySQL Server (for example mysql-essential-5.1.54-win32.msi) or later. We strongly recommend you install MySQL in the folder c: / MySQL / (or other folder name without spaces (MinGW does not understand spaces in the names of directories)). The installation process is sufficient to choose only one item to install - "C Include Files / Lib Files". (Hereinafter referred to as I have found in the directory C: / MySQL /).

    For ease of execution of commands in a terminal to a system variable Path: "C: \ Qt \ 2010.05 \ qt \ bin \; C: \ Qt \ 2010.05 \ mingw \ bin \". These directories are executable files qmake, mingw32make, g + +. REBOOT.

    In the terminal, go to QTDIR / src / plugins / sqldrivers / mysql (cd C: \ Qt \ 2010.05 \ qt \ src \ plugins \ sqldrivers \ mysql)

    Perform qmake-o Makefile "INCLUDEPATH + = C: / MySQL / include" "LIBS + = C: / MySQL / lib / opt / libmysql.lib" mysql.pro

    Perform mingw32-make

    If all goes well, then copy the libmysql.dll from the bin folder of MySQL server installed in QTDIR / bin (I have copied in the folders specified in the PATH)

    NB! If you must use a hands QTSDK copy obtained by compiling the library (qsqlmysqld4.dll, libqsqlmysqld4.a) in the following directories:
    \ QtSDK \ Desktop \ Qt \ 4.7.3 (or another version) \ mingw \ plugins \ sqldrivers (if you're using a different version of it in the appropriate folder to be copied as well)
    \ QtSDK \ Desktop \ Qt \ 4.7.3 (...)\ mingw \ bin
    \ QtSDK \ mingw \ bin

    Restart.

    For MacOs X
    Download and install QTSDK. After this, go to the configuration utility and install additional islhodnye codes.
    Download and affix the software package MySQL (for example a mysql-5.1.53-osx10.6-x86_64.dmg, although the service I did not start.)
    Next, look for a folder with qmake (/ Users/inbush/QtSDK/Desktop/Qt/471/gcc/bin/qmake)
    Folder with the source MySQL (/ usr/local/mysql-5.1.53-osx10.6-x86_64/include)
    Open a terminal and go to the folder plugin (Creativus: ~ inbush $ cd / Users/inbush/QtSDK/QtSources/4.7.1/src/plugins/sqldrivers/mysql)
    Putting the project / Users/inbush/QtSDK/Desktop/Qt/471/gcc/bin/qmake-o Makefile "INCLUDEPATH = / usr/local/mysql-5.1.53-osx10.6-x86_64/include" "LIBS =- L / usr/local/mysql-5.1.53-osx10.6-x86_64/lib-lmysqlclient_r "mysql.pro
    make
    make install

    FOR WINDOWS

    You just can unzip files from the attachment (can't upload the compiled drivers (1.2 mb). If you need them write your e-mail and i'll send you them) and copy them in
    \QtSDK\Desktop\Qt\4.7.3(or another version)\mingw\plugins\sqldrivers (if you're using a different version of it in the appropriate folder to be copied as well)
    \QtSDK\Desktop\Qt\4.7.3(...)\mingw\bin
    \QtSDK\mingw\bin

    PS
    Don't forget to add "QT += sql" in .pro file!

Similar Threads

  1. MySQL 5.5 plugin
    By Rhayader in forum Installation and Deployment
    Replies: 9
    Last Post: 7th June 2012, 21:27
  2. MySql plugin
    By hubipet in forum Installation and Deployment
    Replies: 0
    Last Post: 7th August 2010, 12:23
  3. plugin in mysql n qt
    By kazal in forum Qt Programming
    Replies: 10
    Last Post: 24th June 2010, 12:02
  4. after plugin Mysql n Qt..??
    By kazal in forum Newbie
    Replies: 0
    Last Post: 23rd June 2010, 10:44
  5. MySQL plugin
    By ksqt in forum Installation and Deployment
    Replies: 12
    Last Post: 24th September 2009, 14:26

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.