Results 1 to 7 of 7

Thread: [URGENT] How to connect MySQL with Qt 4.7.3?

  1. #1
    Join Date
    Dec 2011
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default [URGENT] How to connect MySQL with Qt 4.7.3?

    Hello,

    I was trying to connect my Qt code with MySQL Database. However, I got to know that only SQLite is supported in open source Qt and we need to get the drivers for MySQL on our own. Can anyone please tell me How to do it?

    And most IMPORTANT: I have searched google and yahoo and a lot. All I got is simply some $QTDIR/src/plugins/ and ….
    However, I don’t have any file or directory named /src/ in my Qt installation.
    I am here by providing what I am using and will look forward to your suggestion:

    1. Qt SDK 4.7.3
    2. MySQL
    3. Qt installation folder: /home/pkr/QtSDK
    4. MySQL installation: /usr/share/mysql
    5. OS: Ubuntu 12.04
    6: DM: GNOME 3.0

    Please help me out!!! It’s urgent
    Last edited by codeartist; 23rd May 2012 at 16:10.

  2. #2
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: [URGENT] How to connect MySQL with Qt 4.7.3?

    I don't know how much googeling you did but in the last minute I invested out of curiosity I found Qt database drivers and MySQL Connector C++.

  3. #3
    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: [URGENT] How to connect MySQL with Qt 4.7.3?

    [wiki]Building the Database Plugins for QtSDK Users[/wiki]
    Last edited by ChrisW67; 24th May 2012 at 08:05.

  4. The following user says thank you to ChrisW67 for this useful post:

    codeartist (24th May 2012)

  5. #4
    Join Date
    Dec 2011
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [URGENT] How to connect MySQL with Qt 4.7.3?

    Thanks for the replies guys.
    I really appreciate the help.
    @ChrisW67: Can you please help me out in figuring out this problem. I need it urgently to submit my project in college. I am stuck at this point. It's too frustating. I have installed Qt 4.7.3 SDK in /home/pkr/QtSDK/....

    Now after getting some response from different forum I have downloaded the sources file from here (4.8.2). Now I am not able to understand anything how to install it. Please help me out. I need the help and not able to understand anything. I will be greatful to you

  6. #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: [URGENT] How to connect MySQL with Qt 4.7.3?

    @ChrisW67: Can you please help me out in figuring out this problem. I need it urgently to submit my project in college.
    Reminds me of some wise words, "Lack of planning on your part does not constitute an emergency on my part"

    I'll highlight the section from the wiki page I wrote and linked to because I am tired of answering this question:
    The first item most people notice is that the documentation refers to the Qt source at a folder called "%QTDIR%\src\plugins\sqldrivers\..." and that no such directory exists in your Qt SDK. The Qt SDK does not, by default, install the Qt source code, just a compiled version suitable for a particular compiler tool chain (MingW or MSVC). So, the first thing you need to do is download the Qt source code matching the binary version you have installed already. You do this using the Qt SDK Maintenance Tool.
    Now, since you did not follow the instructions you are in a slightly different position. Unpack the source code you downloaded separately to anywhere you like. Let's say you end up with "C:\qt-everywhere-opensource-src-4.8.2" containing a few files and a bunch of directories. Just so there is no confusion, its content looks like this:
    Qt Code:
    1. bin configure examples LGPL_EXCEPTION.txt LICENSE.LGPL README translations
    2. changes-4.8.2 configure.exe imports lib mkspecs src util
    3. config.profiles demos include LICENSE.FDL projects.pro templates
    4. config.tests doc INSTALL LICENSE.GPL3 qmake tools
    To copy to clipboard, switch view to plain text mode 
    That directory is the equivalent of "%QTDIR%" in the documentation on building the database plugins and on the wiki page. Everything else is just following the instructions.

    Also, the source code for Qt 4.8.2 you downloaded does not match the binary version of Qt you told us you were using, that is 4.7.3, in your first post. You might get away with it using this source, or you could obtain the correct source using the Qt SDK Maintenance Tool as directed.
    Last edited by ChrisW67; 24th May 2012 at 23:55.

  7. #6
    Join Date
    Dec 2011
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [URGENT] How to connect MySQL with Qt 4.7.3?

    Really very much thanks! You are great!
    Thanks for helping a novice like me. I will try not to commit such mistake again
    Thanks

  8. #7
    Join Date
    Dec 2011
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [URGENT] How to connect MySQL with Qt 4.7.3?

    C:\QtSDK\QtSources\473\src\plugins\sqldrivers\mysq l>mingw32-make

    mingw32-make -f Makefile.Debug
    mingw32-make[1]: Entering directory `C:/QtSDK/QtSources/473/src/plugins/sqldrive
    rs/mysql'
    g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
    DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_PLUGIN -DQT_SQL_LIB -
    DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_H
    AVE_SSE2 -DQT_THREAD_SUPPORT -I"c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtCor e"
    -I"c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtSql " -I"c:\QtSDK\Desktop\Qt\4.7.3\m
    ingw\include" -I"c:\Program" -I"Files\MySQL\MySQL" -I"Server" -I"5.5\include" -I
    "c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\Activ eQt" -I"debug" -I"c:\QtSDK\Desktop
    \Qt\4.7.3\mingw\mkspecs\default" -o debug\main.o main.cpp
    In file included from main.cpp:44:
    ../../../sql/drivers/mysql/qsql_mysql.h:52:19: error: mysql.h: No such file or d
    irectory
    In file included from main.cpp:44:
    ../../../sql/drivers/mysql/qsql_mysql.h:108: error: expected ')' before '*' toke
    n
    mingw32-make[1]: *** [debug/main.o] Error 1
    mingw32-make[1]: Leaving directory `C:/QtSDK/QtSources/473/src/plugins/sqldriver
    s/mysql'
    mingw32-make: *** [debug] Error 2
    This is the problem I am getting after I executed mingw32-make.
    @Chris: Can you please help me in this?

Similar Threads

  1. Replies: 13
    Last Post: 17th June 2011, 17:19
  2. How to connect Qt with MYSQL??
    By Gokulnathvc in forum Newbie
    Replies: 10
    Last Post: 24th March 2011, 00:52
  3. Qt connect different MySQL
    By weixj2003ld in forum Qt Programming
    Replies: 0
    Last Post: 5th August 2009, 08:35
  4. How to connect MySQL with QT
    By diego in forum Qt Programming
    Replies: 0
    Last Post: 27th May 2009, 05:34
  5. [URGENT] Weird compile error [URGENT]
    By MarkoSan in forum Qt Programming
    Replies: 3
    Last Post: 24th May 2008, 23:54

Tags for this Thread

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.