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. [SOLVED] Problems with Database Drivers (Linux)
QtWS25 Last Chance

[SOLVED] Problems with Database Drivers (Linux)

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.2k Views
  • 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.
  • M Offline
    M Offline
    mikeosoft
    wrote on last edited by
    #1

    My configuration is:
    Qt Creator 3.2.0
    Based on Qt 5.3.1 (GCC 4.6.1, 64 bit)
    From revision bld8156742

    Running on Linux Mint 17 KDE 64 Bit

    I am having problems loading the database driver.

    I have reduced things to as simple as possible, so that the database is being declared locally, though I initially had the same problem when it was declared it as a property within a class.

    I am trying to use Maria DB from a server, though it fails at the point of trying to load the driver, before it even tries to make the connection (so actually the database could be mysql, MariaDB or something else).

    It works for:

    • QSQLITE (which I use in other projects).

    I find that it Fails in the same way for:

    • QMYSQL
    • QMYSQL3
    • QPSQL
    • QPSQL7

    The error message I get is:
    @QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7@

    The header files I am using are:
    @#include <QObject>
    #include <QSqlDatabase>
    #include <QSqlQuery>
    #include <QMessageBox>
    #include <QVariant>
    #include <QSqlError>
    #include <QSqlDriver>
    #include <QDebug>@

    I copied the code from the Documentation on the Website:
    @QSqlDatabase m_DB = QSqlDatabase::addDatabase("QMYSQL");
    qDebug() << "1.\t"<< m_DB.isValid();
    @

    I also tried this:
    @QSqlDatabase m_DB;
    m_DB = QSqlDatabase::addDatabase("QMYSQL");
    qDebug() << "1.\t"<< m_DB.isValid();@

    The isValid() method is false for every attempt other than the QSQLITE.

    This is what I have in my profile for the project:
    @QT += core gui
    QT += sql
    QT += network
    QT += printsupport

    CONFIG += qt warn_on
    CONFIG += c++11@

    Am I missing something obvious, not including a header or something like that, help would be apprieciated.

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      You are missing the libraries MYSQL on your box. Ensure that all the required libraries for MYSQL are in path. There are many posts like "here":http://qt-project.org/forums/viewthread/36656. They will surely solve your problem.

      Look at following youtube video as well.
      https://www.youtube.com/watch?v=-kq1J1WkmxM

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mikeosoft
        wrote on last edited by
        #3

        I used this "link":http://qt-project.org/doc/qt-5/sql-driver.html to help me.

        On my system $QTDIR wasn't set to anything, so I worked out where it was by searching for the "mysq.pro" file.

        When I tried to run qmake, I needed to use the 5.3 version, rather than any others, so I searched and found that and used the full path to it.

        @$cd /home/mike/Qt/5.3/Src/qtbase/src/plugins/sqldrivers/mysql
        $/home/mike/Qt/5.3/gcc_64/bin/qmake mysql.pro
        make
        sudo make install@

        I was confused because I felt the error message was telling me to use a driver that it also suggested was installed on the computer, the actual problem was that it lacked a dependency.

        I tried hard to resolve the dependency and then tried to just rebuild the library and that worked.

        Thanks to Dheerendra for the help.

        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