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. QtCreator:How to write MySQl IncludePath on *.pro file?
Forum Updated to NodeBB v4.3 + New Features

QtCreator:How to write MySQl IncludePath on *.pro file?

Scheduled Pinned Locked Moved Installation and Deployment
9 Posts 4 Posters 6.5k 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.
  • H Offline
    H Offline
    Hiwasawa
    wrote on 22 Jan 2013, 03:22 last edited by
    #1

    I'm Japanese student.
    And now, I'm tring to connect MySQL server.

    I use Windows7 64bit, Qt 4.8.3(32bit) Qt Creator2.6.1 MySQL 5.5.29.
    Qt creator use minGW.

    So, I tryed write ↓ to "*.pro" files.
    INCLUDEPATH += C:\Program Files\MySQL\MySQL Server 5.5\include

    And I tryed build.
    Thisu is the error message.
    ↓
    g++: error: C:\Program: No such file or directory
    g++: error: Files\MySQL\MySQL: No such file or directory
    g++: error: Server: No such file or directory
    g++: error: 5.5\lib\libmysql.lib: No such file or directory
    mingw32-make[1]: *** [debug\MySQLTest02.exe] Error 1
    mingw32-make: *** [debug] Error 2

    I can't understand why
    "g++: error: C:\Program Files: No such file or directory"
    not "g++: error: C:\Program: No such file or directory"

    Is space not available on QtCreator ?

    1 Reply Last reply
    0
    • H Offline
      H Offline
      holygirl
      wrote on 22 Jan 2013, 03:48 last edited by
      #2

      You just include

      @QT += sql@

      in the .pro file. You can specify the path of your database in the source file as

      @
      QSqlDatabase db = QSqlDatabase::addDatabase("MySQL");
      db.setDatabaseName("C:\Program Files\MySQL\MySQL Server 5.5\include\databasename.db");
      db.open();
      @

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Code_ReaQtor
        wrote on 22 Jan 2013, 03:59 last edited by
        #3

        @holygirl, I think his goal is to add the "specific" MySQL libraries and not using th QSqlDatabase class.

        @Hiwasawa

        add quotes (")
        here is the "explanation":http://doc.qt.digia.com/qt/qmake-project-files.html#whitespace

        Please visit my open-source projects at https://github.com/Code-ReaQtor.

        1 Reply Last reply
        0
        • H Offline
          H Offline
          holygirl
          wrote on 22 Jan 2013, 04:09 last edited by
          #4

          Oops! My bad. Thank you for pointing it out Code_ReaQtor.

          1 Reply Last reply
          0
          • H Offline
            H Offline
            Hiwasawa
            wrote on 22 Jan 2013, 07:15 last edited by
            #5

            Thank you for your reply !!!
            and now I tryed the way by "Code_ReaQtor".

            I tryed this code.

            INCLUDEPATH += $$quote(C:\Program Files\MySQL\MySQL Server 5.5\include)
            LIBS += $$quote(C:\Program Files\MySQL\MySQL Server 5.5\lib\libmysql.lib)

            And the error of build resolved!

            But,,,
            Now There is an error on Console.
            ----Eror message----------------------------------------------------------
            QSqlDatabase: QMYSQL driver not loaded
            QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC

            but, my directory is this

            C:\Qt\4.8.4\include\QtSql\QMYSQLDriver
            C:\Qt\4.8.4\include\QtSql\QMYSQLResult

            how to use QMYSQL driver ?

            1 Reply Last reply
            0
            • H Offline
              H Offline
              Hiwasawa
              wrote on 22 Jan 2013, 07:19 last edited by
              #6

              my project is only this

              MySQLTest02--MySQLTest02.pro
              |
              -source---main.cpp

              MySQLTest02.pro---------------------------

              QT += core
              QT += sql
              QT -= gui

              INCLUDEPATH += $$quote(C:\Program Files\MySQL\MySQL Server 5.5\include)
              LIBS += $$quote(C:\Program Files\MySQL\MySQL Server 5.5\lib\libmysql.lib)

              TARGET = MySQLTest02
              CONFIG += console
              CONFIG -= app_bundle

              TEMPLATE = app
              SOURCES += main.cpp

              main.cpp------------------------------------

              #include <QCoreApplication>
              #include <QSqlDatabase>
              #include <QDebug>
              #include <QSqlError>
              #include<iostream>

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

              QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
               db.setHostName("localhost");
               db.setDatabaseName("test");
               db.setUserName("root");
               db.setPassword("hiwahiwa0715");
               if(!db.open()){
              
               }
              return a.exec&#40;&#41;;
              

              }


              1 Reply Last reply
              0
              • B Offline
                B Offline
                BelenMuñoz
                wrote on 22 Jan 2013, 07:41 last edited by
                #7

                I had the same problem a few weeks ago.
                I solved it compiling in Release mode and adding the plugin libraries to the solution folder.
                Hope it helps you.

                Regards.

                Me casé con un enano pa jartarme de reí.

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  Code_ReaQtor
                  wrote on 22 Jan 2013, 07:41 last edited by
                  #8

                  bq. INCLUDEPATH += $$quote(C:\Program Files\MySQL\MySQL Server 5.5\include)
                  LIBS += $$quote(C:\Program Files\MySQL\MySQL Server 5.5\lib\libmysql.lib)

                  Correct me if I am wrong... you wanted to use MySQL in the QSqlDatabase?

                  Then the thing you added in the .pro file has nothing to do with it...

                  bq. QSqlDatabase: QMYSQL driver not loaded
                  QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC

                  What you need is the QMYSQL plugin/driver for Qt. You actually need to build/rebuild Qt yourself and passing "-qt-sql-mysql" to configure

                  Please visit my open-source projects at https://github.com/Code-ReaQtor.

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    Hiwasawa
                    wrote on 22 Jan 2013, 08:26 last edited by
                    #9

                    Thank you.

                    Correct me if I am wrong… you wanted to use MySQL in the QSqlDatabase?
                    Yeah, I want to use MySQL in th QSqlDatabase.
                    I knew the module from a book about Qt from O'REILLY.
                    but the book don't written about how to configure the environment.

                    Then the thing you added in the .pro file has nothing to do with it…
                    ohh, really? so how to recognition the Qtcreator to the include path of MySQL?

                    What you need is the QMYSQL plugin/driver for Qt. You actually need to build/rebuild Qt yourself and >passing “-qt-sql-mysql” to configure

                    ohh, it will need very very long time.

                    1 Reply Last reply
                    0

                    1/9

                    22 Jan 2013, 03:22

                    • Login

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