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. QODBC not available Qt 11.1
Qt 6.11 is out! See what's new in the release blog

QODBC not available Qt 11.1

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 4 Posters 1.4k 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.
  • M Offline
    M Offline
    MartinPobel
    wrote on last edited by MartinPobel
    #1

    Hello,

    I did a program on Qt 5.6 where I had to connect to a SQL serveur with ODBC driver. I'm using Ubuntu 16.
    I faced some problems I saw on topics : I installed the librairies and changed the odbcinst.ini and it was working well !!

    Then I had to build and execute this program on Qt 11.1 but the driver qsqlodbc is not available in the list proposed :

    QSqlDatabase: QODBC3 driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
    

    Indeed when I go to "Qt/5.11.1/gcc_64/plugins/sqldrivers" I can't find the libqsqlodbc.so.
    This file is available in "Qt/5.6.3/gcc_64/plugins/sqldrivers".

    I tried without hope to copy the one from 5.6 to 5.11 but obviously it not working because it is not the same version .

    Do you have any idea how to have this file available in Qt 5.11 ?

    Thank you,

    Martin

    1 Reply Last reply
    0
    • jsulmJ jsulm

      @MartinPobel said in QODBC not available Qt 11.1:

      how to choose the correct qmake

      Just use full path when calling it.

      "Isn't it ok to use 5.9.5 ?" - didn't you write you want to build it for Qt 5.11?

      M Offline
      M Offline
      MartinPobel
      wrote on last edited by
      #9

      ok it is working !!
      Thanks a lot !!

      I didn't figure out the qmake choice so i'm trying to explain it here for beginner :
      (it is quite easy and obvious when you know it but it didn't)
      When you follow this code :
      It says that you have to execute just those 3 lines :

      cd $QTDIR/qtbase/src/plugins/sqldrivers
      qmake -- ODBC_PREFIX=/usr/local/unixODBC
      make sub-odbc
      

      First to have access to cd $QTDIR/qtbase/src/plugins/sqldrivers you need to get the sources from Qt Maintenance Tool.
      Then the qmake (where I had a lot of problems) : As @jsulm and @Christian-Ehrlicher tried to explained me you have to choose the right one. For me I had to execute this line because I was trying to compile for Qt11 :

      $ /home/martin/Qt/5.11.1/gcc_64/bin/qmake -- ODBC_PREFIX=/usr/local/unixODBC
      

      Then execute :

      make sub-odbc
      

      If you have an error :

      ../../../sql/drivers/mysql/qsql_mysql.cpp:36:40: fatal error: QtSql/private/qsqldriver_p.h: No such file or directory
       #include <QtSql/private/qsqldriver_p.h>
      

      you need to install qtbase5-private-dev

      sudo apt-get install qtbase5-private-dev
      
      1 Reply Last reply
      2
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #2

        Compile the plugin yourself. Instructions are at the bottom of https://doc.qt.io/qt-5/sql-driver.html#qodbc

        (Z(:^

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

          Thank you !
          I'm trying to do so but when I run : make sub-odbc in the terminal I get an error :

          cd odbc/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /home/martin/Qt/5.11.1/Src/qtbase/src/plugins/sqldrivers/odbc/odbc.pro ODBC_PREFIX=/usr/local/unixODBC-2.3.7 ) && make -f Makefile
          make[1] : on entre dans le répertoire « /home/martin/Qt/5.11.1/Src/qtbase/src/plugins/sqldrivers/odbc »
          g++ -c -g -O2 -fdebug-prefix-map=/build/qtbase-opensource-src-5DihdB/qtbase-opensource-src-5.9.5+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -O2 -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -Wdate-time -Wshift-overflow=2 -Wduplicated-cond -Wno-stringop-overflow -D_REENTRANT -fPIC -DUNICODE -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -isystem /usr/include/x86_64-linux-gnu/qt5/QtSql/5.9.5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtSql/5.9.5/QtSql -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore/5.9.5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore/5.9.5/QtCore -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtSql -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I.moc -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o .obj/qsql_odbc.o qsql_odbc.cpp
          qsql_odbc.cpp: In function ‘QSqlField qMakeFieldInfo(SQLHANDLE, int, QString*)’:
          qsql_odbc.cpp:741:11: error: ‘class QSqlField’ has no member named ‘setTableName’; did you mean ‘setName’?
                   f.setTableName(fromSQLTCHAR(tableName, tableNameLen));
                     ^~~~~~~~~~~~
                     setName
          Makefile:378: recipe for target '.obj/qsql_odbc.o' failed
          make[1]: *** [.obj/qsql_odbc.o] Error 1
          

          I check on QSqlField Qt11.1 documentation, this member setTableName does exist.
          But I don't know why in the make it is written "QtSq;/5.9.11" when i never installed Qt5.9 on my computer, I used 5.6 and now 5.11.

          I really don't understand.

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by Christian Ehrlicher
            #4

            what does 'qmake -version' prints out?
            Make sure to call the correct qmake executable for your Qt version.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            0
            • M Offline
              M Offline
              MartinPobel
              wrote on last edited by
              #5

              Hi,
              The qmake -version returns :

              QMake version 3.1
              Using Qt version 5.9.5 in /usr/lib/x86_64-linux-gnu
              

              I didn't choose qmake when I did qmake -- ODBC_PREFIX=/usr/local/unixODBC-2.3.7

              1 Reply Last reply
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #6

                @MartinPobel said in QODBC not available Qt 11.1:

                I didn't choose qmake when I did

                You did - since it's in your PATH. Make sure to use the correct one. Remove qmake.cache and other generated stuff before running the correct qmake again.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                1
                • M Offline
                  M Offline
                  MartinPobel
                  wrote on last edited by
                  #7

                  I'm still having the same error.

                  I don't understand how to choose the correct qmake.
                  Isn't it ok to use 5.9.5 ?
                  I'm guessing i'm not the first one to compile this driver on Qt 5.11 and I couldn't find another person with this problem.

                  What am I doing wrong ?

                  jsulmJ 1 Reply Last reply
                  0
                  • M MartinPobel

                    I'm still having the same error.

                    I don't understand how to choose the correct qmake.
                    Isn't it ok to use 5.9.5 ?
                    I'm guessing i'm not the first one to compile this driver on Qt 5.11 and I couldn't find another person with this problem.

                    What am I doing wrong ?

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by jsulm
                    #8

                    @MartinPobel said in QODBC not available Qt 11.1:

                    how to choose the correct qmake

                    Just use full path when calling it.

                    "Isn't it ok to use 5.9.5 ?" - didn't you write you want to build it for Qt 5.11?

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    M 1 Reply Last reply
                    2
                    • jsulmJ jsulm

                      @MartinPobel said in QODBC not available Qt 11.1:

                      how to choose the correct qmake

                      Just use full path when calling it.

                      "Isn't it ok to use 5.9.5 ?" - didn't you write you want to build it for Qt 5.11?

                      M Offline
                      M Offline
                      MartinPobel
                      wrote on last edited by
                      #9

                      ok it is working !!
                      Thanks a lot !!

                      I didn't figure out the qmake choice so i'm trying to explain it here for beginner :
                      (it is quite easy and obvious when you know it but it didn't)
                      When you follow this code :
                      It says that you have to execute just those 3 lines :

                      cd $QTDIR/qtbase/src/plugins/sqldrivers
                      qmake -- ODBC_PREFIX=/usr/local/unixODBC
                      make sub-odbc
                      

                      First to have access to cd $QTDIR/qtbase/src/plugins/sqldrivers you need to get the sources from Qt Maintenance Tool.
                      Then the qmake (where I had a lot of problems) : As @jsulm and @Christian-Ehrlicher tried to explained me you have to choose the right one. For me I had to execute this line because I was trying to compile for Qt11 :

                      $ /home/martin/Qt/5.11.1/gcc_64/bin/qmake -- ODBC_PREFIX=/usr/local/unixODBC
                      

                      Then execute :

                      make sub-odbc
                      

                      If you have an error :

                      ../../../sql/drivers/mysql/qsql_mysql.cpp:36:40: fatal error: QtSql/private/qsqldriver_p.h: No such file or directory
                       #include <QtSql/private/qsqldriver_p.h>
                      

                      you need to install qtbase5-private-dev

                      sudo apt-get install qtbase5-private-dev
                      
                      1 Reply Last reply
                      2

                      • Login

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