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. Error: "Qtsql/Qtsql: No such file or directory"
Forum Updated to NodeBB v4.3 + New Features

Error: "Qtsql/Qtsql: No such file or directory"

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 5.6k Views 2 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.
  • B Offline
    B Offline
    Bob W
    wrote on last edited by A Former User
    #1

    I already looked up the older previous posting on this , but none worked.
    I tested a new QT console App for MySQL connector C on Windows 7.
    It worked fine.
    I redid the same on Ubuntu 16.04 MySQL Server version: 5.7.17 with a new linux 32 bit library, but got the compile error:
    " Qtsql/Qtsql: No such file or directory."
    ( I only used the 1 OS and unchecked options for each different OS )
    The pro file was relinked as shown:

    QT += core
    QT += sql
    QT -= gui
    
    TARGET = testdb
    CONFIG += console
    CONFIG -= app_bundle
    TEMPLATE = app
    SOURCES += main.cpp
    
    unix:!macx: LIBS += -L$$PWD/../MySQl/mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit/lib/ -lmysql
    
    INCLUDEPATH += $$PWD/../MySQl/mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit/include
    DEPENDPATH += $$PWD/../MySQl/mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit/include
    

    The main.cpp file:

    #include <QCoreApplication>
    #include <Qtsql/Qtsql>
    #include <Qtsql/QSqlDatabase>
    #include <Qtsql/QSqlQuery>
    
    #include <iostream>
    using namespace std;
    
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
        // create database connection
        QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
        db.setHostName("localhost");
        db.setUserName("root");
        db.setPassword("");
        db.setDatabaseName("testdb");
        if (db.open()) {
            cout << "Database connected" << endl;
        }
        else {
            cout << "Database connect failed" << endl;
        }
        string userid, username, userstate, userphone;
        QSqlQuery mysqlquery;
        mysqlquery.exec("SELECT * FROM student");
    
        if (mysqlquery.size() > 0) {
            while (mysqlquery.next()){
                userid = mysqlquery.value("id").toString().toUtf8().constData();
                username = mysqlquery.value("name").toString().toUtf8().constData();
                userstate = mysqlquery.value("state").toString().toUtf8().constData();
                userphone = mysqlquery.value("phone").toString().toUtf8().constData();
    
                cout << userid <<" - "<< username <<" - "<< userstate <<" - "<< userphone<< endl;
            }
        }
        else{
    
    
        }
        return a.exec();
    }
    

    I tried both the Mysql connector C & C++, same result.

    Any ideas?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! Did you install Qt via the online installer, the offline installer or through Ubuntu's package manager?

      1 Reply Last reply
      1
      • B Offline
        B Offline
        Bob W
        wrote on last edited by
        #3

        I do not remember.
        I did not see it in the Ubuntu package manager, so I think it was an apt-get install.
        The Help is Qt Creator 3.5.1 Based on Qt5.5.1 (GCC 5.2.1 20151129, 32 bit )

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by A Former User
          #4

          Looking at the list of contents of Ubuntu's package qtbase5-dev:

          /usr/include/x86_64-linux-gnu/qt5/QtSql/QSql
          /usr/include/x86_64-linux-gnu/qt5/QtSql/QSqlDatabase
          /usr/include/x86_64-linux-gnu/qt5/QtSql/QSqlDriver
          /usr/include/x86_64-linux-gnu/qt5/QtSql/QSqlDriverCreator
          /usr/include/x86_64-linux-gnu/qt5/QtSql/QSqlDriverCreatorBase
          /usr/include/x86_64-linux-gnu/qt5/QtSql/QSqlDriverPlugin
          /usr/include/x86_64-linux-gnu/qt5/QtSql/QSqlError
          /usr/include/x86_64-linux-gnu/qt5/QtSql/QSqlField
          /usr/include/x86_64-linux-gnu/qt5/QtSql/QSqlIndex
          /usr/include/x86_64-linux-gnu/qt5/QtSql/QSqlQuery
          /usr/include/x86_64-linux-gnu/qt5/QtSql/QSqlQueryModel
          /usr/include/x86_64-linux-gnu/qt5/QtSql/QSqlRecord
          /usr/include/x86_64-linux-gnu/qt5/QtSql/QSqlRelation
          /usr/include/x86_64-linux-gnu/qt5/QtSql/QSqlRelationalDelegate
          /usr/include/x86_64-linux-gnu/qt5/QtSql/QSqlRelationalTableModel
          /usr/include/x86_64-linux-gnu/qt5/QtSql/QSqlResult
          /usr/include/x86_64-linux-gnu/qt5/QtSql/QSqlTableModel
          /usr/include/x86_64-linux-gnu/qt5/QtSql/QtSql
          /usr/include/x86_64-linux-gnu/qt5/QtSql/QtSqlDepends
          /usr/include/x86_64-linux-gnu/qt5/QtSql/QtSqlVersion

          So I assume it's just typos in your includes. Try to change them to:

          #include <QtSql/QtSql>
          #include <QtSql/QSqlDatabase>
          #include <QtSql/QSqlQuery>
          
          1 Reply Last reply
          2
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by VRonin
            #5
            This post is deleted!
            1 Reply Last reply
            0
            • B Offline
              B Offline
              Bob W
              wrote on last edited by
              #6

              That was it.
              Must have been a typo !
              Thanks.

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                Great :-) Please use the topic tools to mark the thread as solved (see Hitchhiker's Visual Guide to the Qt Forum for 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