Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MySQL "libs & include" module not found
Forum Updated to NodeBB v4.3 + New Features

MySQL "libs & include" module not found

Scheduled Pinned Locked Moved General and Desktop
mysqlqt5
3 Posts 2 Posters 2.6k 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.
  • _ Offline
    _ Offline
    _Mark_
    wrote on last edited by
    #1

    Hi!
    I'm reading the documentation about how to use MySQL in Qt5 applications:

    http://doc.qt.io/qt-5/sql-driver.html#qmysql

    It says:

    You need to get the MySQL installation files. Run SETUP.EXE and choose "Custom Install". Install the "Libs & Include Files" Module. 
    

    But I cannot find this module in the MySQL installation! I downloaded the last version of the community release.
    Am I missing something obvious?

    1 Reply Last reply
    0
    • N Offline
      N Offline
      NetZwerg
      wrote on last edited by
      #2

      For Windows:
      Download the MySQL Server or the libmysqlclient c connector
      When using the connector you can easily take the zip-only and extract this to some temporary directory.

      You need to link against the libmysql.dll by having INCLUDEPATH set to include the mysql.h directory and LIBS set to include (-L) the lib-path and the library to link against (-l).

      cd %QTDIR%/src/qtbase/src/plugins/sqldrivers/mysql
      qmake "CONFIG+=release" "INCLUDEPATH+=C:/temp/mysqlconnector/include" "LIBS+=-LC:/temp/mysqlconnector/lib" "LIBS+=-llibmysql" mysql.pro
      (n|mingw32-)make
      (n|mingw32-)make install
      

      For Linux:
      Install the apropriate header files for your linux destribution.

      1 Reply Last reply
      0
      • _ Offline
        _ Offline
        _Mark_
        wrote on last edited by _Mark_
        #3

        Thank you! With your hints I successfully compiled the plugins, which are place into:

        C:\Development\Qt\5.5\mingw492_32\plugins\sqldrivers
        

        Now I'm facing the common issue of "QMYSQL driver not loaded but available". I read tons of thread about this but I'm asking some clarification about.

        1. I checked the db server is up (from MySQL Workbench I can connect)

        2. in the pro file of my test app I set:

        QT += sql
        
        1. this is my connection code:
            QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
            db.setHostName("localhost");
            db.setPort(3306);
            db.setDatabaseName("test");
            db.setUserName("root");
            db.setPassword("");
            qDebug() <<  db.open();
        

        in the documentation I cannot find the page where are described the requisites, like which libs to link with, etc...

        EDIT:
        the error is present only in debug mode1 In release it connect successfully! Anyway I have also qsqlmysqld.dll in the plugins folder.

        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