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. Install mysql driver for qt in ubuntu
Forum Updated to NodeBB v4.3 + New Features

Install mysql driver for qt in ubuntu

Scheduled Pinned Locked Moved Installation and Deployment
47 Posts 8 Posters 65.7k 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.
  • D Offline
    D Offline
    doforumda
    wrote on last edited by
    #1

    hi,

    I want to install mysql driver for qt on ubuntu. I install qt creator 2.0.1. Anyone who can help me installing and make it work for qt?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

      Just install libqt4-sql-mysql package if you use Qt from repository. If you use Qt built from sources, than you need to install mysql-dev headers and libraries and build mysql plugin from src/plugins/sqldrivers/mysql.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        doforumda
        wrote on last edited by
        #3

        i followed steps in this url

        "http://prres.wordpress.com/2010/05/17/configure-mysql-database-driver-for-qt/":http://prres.wordpress.com/2010/05/17/configure-mysql-database-driver-for-qt/

        the first is done perfect but the second step is not working for me. when i do first line in second step it displays this
        @-bash: cd/src/plugins/sqldrivers/mysql: No such file or directory@

        when i checked these directories “/usr/incluce/mysql” and “/usr/lib/mysql” it was present there after doing first steps

        [edit: url made clickable / Denis Kormalev]

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DenisKormalev
          wrote on last edited by
          #4

          Looks like you've forgotten space and qt path in your command. For example in my system qt sources are in /usr/src/qt, so commands for me will be:
          @
          cd /usr/src/qt/src/plugins/sqldrivers/mysql
          qmake "INCLUDEPATH+=/usr/include/mysql" "LIBS+=-L/usr/lib/mysql -lmysqlclient_r" mysql.pro
          make
          @

          1 Reply Last reply
          0
          • D Offline
            D Offline
            doforumda
            wrote on last edited by
            #5

            when i was installing qt creator it tells me this path /opt/sqt

            1 Reply Last reply
            0
            • D Offline
              D Offline
              DenisKormalev
              wrote on last edited by
              #6

              You need not libraries, but sources. I don't remember if they are distributing with Qt SDK. Look for folder src somewhere in /opt/qt

              1 Reply Last reply
              0
              • D Offline
                D Offline
                doforumda
                wrote on last edited by
                #7

                ok i found opt/qt and sub directories in it. Now when i run qmake command it says this
                @qpluginbase.pri:10: unknown replace function qtLibraryTarget

                Failure to open file opt/qtsdk-2010.05/qt/src/plugins/sqldrivers/mysql/MakeFile@

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  DenisKormalev
                  wrote on last edited by
                  #8

                  Looks like it can't find mkspecs/features folder (with prf file describing this replace function).

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    doforumda
                    wrote on last edited by
                    #9

                    any help what should i do now?

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      DenisKormalev
                      wrote on last edited by
                      #10

                      As a quick solution you can rebuild Qt library from source :)

                      Another way:
                      Look into your built Qt library for file mkspecs/features/qt_functions.prf. If it isn't there copy this file from src folder, it should help I think.

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mkfnx
                        wrote on last edited by
                        #11

                        "Failure to open file opt/qtsdk-2010.05/qt/src/plugins/sqldrivers/mysql/MakeFile"

                        I just saw this error today when I was trying to compile a Qt Example. Verify that you have writing permission in the /opt/qt folder.

                        1 Reply Last reply
                        0
                        • D Offline
                          D Offline
                          doforumda
                          wrote on last edited by
                          #12

                          hi i checked the file you specified. its here on my pc /home/qt/qt/mkspecs/qt_functions.prf.

                          so how can i run qmake command?

                          1 Reply Last reply
                          0
                          • D Offline
                            D Offline
                            DenisKormalev
                            wrote on last edited by
                            #13

                            Where is your Qt instance located?

                            1 Reply Last reply
                            0
                            • D Offline
                              D Offline
                              doforumda
                              wrote on last edited by
                              #14

                              what do you mean qt instance??

                              1 Reply Last reply
                              0
                              • D Offline
                                D Offline
                                doforumda
                                wrote on last edited by
                                #15

                                can you tell me what do you mean by qt instance?

                                1 Reply Last reply
                                0
                                • D Offline
                                  D Offline
                                  doforumda
                                  wrote on last edited by
                                  #16

                                  i changed file permissions now it displays this error
                                  "qpluginbase.pri:10: Unknown Replace Function: qtLibraryTarget"

                                  [quote author="mkfnx" date="1286424583"]"Failure to open file opt/qtsdk-2010.05/qt/src/plugins/sqldrivers/mysql/MakeFile"

                                  I just saw this error today when I was trying to compile a Qt Example. Verify that you have writing permission in the /opt/qt folder.[/quote]

                                  1 Reply Last reply
                                  0
                                  • D Offline
                                    D Offline
                                    DenisKormalev
                                    wrote on last edited by
                                    #17

                                    By Qt instance I've meant directory where your Qt libraries lives.

                                    1 Reply Last reply
                                    0
                                    • D Offline
                                      D Offline
                                      doforumda
                                      wrote on last edited by
                                      #18

                                      ok let me explain this. I install Qt creator in home diractory. and i created new diractory inside home when i was asked to provide a path for installing Qt creator. Inside this Qt directory there are four directories and a file. these are directories "Bin, lib, qt, share" and file named "License". When i get into Qt subdirectory then i found lots of other dirs and there is also another directory with the name of "lib". Now i dont know which lib directory contains Qt Libraries.

                                      1 Reply Last reply
                                      0
                                      • M Offline
                                        M Offline
                                        mkfnx
                                        wrote on last edited by
                                        #19

                                        Then you have two Qt version's? One in the /opt dir and one in your /home? The home version was installed via the Qt installer? If this is the case, your installation is like mine. So here's what I did:

                                        This is what I have:

                                        • Installation Directory /home/mkfnx/qtsdk-2010.05/
                                        • "Qt Directory" /home/mkfnx/qtsdk-2010.05/qt
                                        • MySQL Plugin Directory /home/mkfnx/qtsdk-2010.05/qt/src/plugins/sqldrivers/mysql/

                                        In the MySQL Plugin Directory I have a project file with the configuration to build the MySQL plugin.

                                        Just run qmake to generate the Makefile and then run make to compile the plugin.

                                        If you get an error thath says that mysql.h cannot be found edit the qsql_mysql.h file and change the line #include <mysql.h> for #include <mysql/mysql.h>

                                        When the build succeds move or copy the file libqsqlmysql.so from the MySQL Plugin Directory to /home/mkfnx/qtsdk-2010.05/qt/plugins/sqldrivers

                                        Also make sure that you're using the right Qt version to build your projects. Note that executing the command "qmake" int a terminal, will execute the Qt version that its referenced in the system path, this is probably the version (that I think that you have) installed in /opt. In Qt Creator shouldn't be any problem because it let's you choose the version that you want to use to build, just pick the right one.

                                        That's how it worked for me. Hope to do it for you too.

                                        1 Reply Last reply
                                        0
                                        • D Offline
                                          D Offline
                                          doforumda
                                          wrote on last edited by
                                          #20

                                          you mean i should run qmake command on plugins.pro inside plugins directory and then make command on this very same file?

                                          1 Reply Last reply
                                          0

                                          • Login

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