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. Qt application crashing when using ODBC driver (macOS)
Forum Updated to NodeBB v4.3 + New Features

Qt application crashing when using ODBC driver (macOS)

Scheduled Pinned Locked Moved Unsolved General and Desktop
20 Posts 6 Posters 6.1k 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.
  • B Offline
    B Offline
    br4in
    wrote on last edited by
    #7

    EDIT : i have to resolve the qmodule.pri error , even if i will workaround the bug ,
    because i have to rebuild with unixODBC due to an reinstallation of QT

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #8

      Again, how are you trying to build the driver and what exact error are you having ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • B Offline
        B Offline
        br4in
        wrote on last edited by
        #9

        Here's how i did :

        I launch a terminal , and i type
        cd ~/Qt/5.7/Src/qtbase/src/plugins/sqldrivers/odbc

        then i type
        qmake "INCLUDEPATH+=/usr/local/unixODBC/include" "LIBS+=-L/usr/local/unixODBC/lib -lodbc" //Here's where the problem appears

        then i run a simple "make"

        it worked to first time , but when i tried to build the iODBC driver , it gives me the error. i that's why i reinstalled the whole Qt (but doesn't resolved a thing)

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #10

          what do you get if you call which qmake ?

          To be sure to use the right one, you should use the full path to the binary.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • B Offline
            B Offline
            br4in
            wrote on last edited by
            #11

            Thank you so much ,
            it turns out that my terminal is using another qmake , it worked when i used the full path.

            so i builded the iODBC driver with this command line :
            /Users/br4in/Qt5.6.2/5.6/clang_64/bin/qmake "INCLUDEPATH+=/usr/local/iODBC/include" "LIBS+=-L/usr/local/iODBC/lib -liodbc"

            it gave no errors , but the app is still crashing when i use the ODBC driver.

            it seems like an issue with QODBC , can you give me the tutorial to workaround the bug ?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #12

              Just apply the patch you can find here and rebuild the driver.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • B Offline
                B Offline
                br4in
                wrote on last edited by
                #13

                I applied the patch , rebuilded the driver and my code.
                but the issue isn't fixed yet :(

                1 Reply Last reply
                0
                • hskoglundH Offline
                  hskoglundH Offline
                  hskoglund
                  wrote on last edited by hskoglund
                  #14

                  Hi, it might be something with Oracle's .dylib for ODBC, which .dylib/client do you use?

                  Qt's libqsqlodbc.dylib works fine for me, but I use it for MS SQLServer together with FreeTDS (libtdsodbc.so). Also in my Qt 5.7 libqsqlodbc.dylib was included so I didn't had to build it myself.

                  Edit: looked at the crash screen above, it indeed seems that the crash is where @SGaist 's patch should help. You could try to patch again, but this time just comment out the whole function, something like this:

                  static QString qWarnODBCHandle(int handleType, SQLHANDLE handle, int *nativeCode = 0)
                  {
                      return "";
                  }
                  

                  That function just returns an additional diagnostic error message, so it's not really needed :-)

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    br4in
                    wrote on last edited by
                    #15

                    Hey , I commented the whole function as you said , except the two above lines :
                    QString result;
                    return result; (because if i type return " " , i will get a constructor error)
                    then i rebuilded the driver and started a new project with the same code.

                    the problem wasn't resolved . Maybe my libqsqlodbc.dylib is executing a different qsql_odbc.cpp file ?

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #16

                      Did you install the driver ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #17

                        Can you check again with 5.8 ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          Mohammad Kanan
                          wrote on last edited by Mohammad Kanan
                          #18

                          Steps to activate/test QODBC on Mac OS ((Seirra) towards MSSQL or any other ODBC DB:

                          Symptom 1: Qt Creator Run (Debug): application crashes (program unexpectedly finished/crashed).
                          Symptom 2: Qt Creator with pre-built Qt packages (Qt installed with MaintenanceTool).

                          Symptom 3: freeTDS driver (libtdsodbc.so) is missing after installing freeTDS packages.

                          Symptom 4: Qt built/configured before installing unixODBC.

                          1. Download and install unixODBC (must be done before installing freeTDS)
                            Go -- > (www.unixODBC.org) / (Drivers) / (unixODBC-2.3.4.tar.gz)
                            unzip and untar the packages.
                            (Make sure you have write permissions otherwise run below last command with sudo prefix)
                          ./configure --prefix=/usr/local/unixODBC
                          make
                          sudo make istall
                          
                          1. Download and install freeTDS:
                            Go --> (http://www.freetds.org/) / ( Quick Links) / (Latest Versions) / (Stable Release)
                            untar/unzip the package.
                          ./configure --prefix=/usr/local/freeTDS --with-unixodbc=/usr/local/unixODBC/
                          make
                          sudo make install
                          

                          Note:
                          --with-unixodbc will cause the driver (libtdsodbc.so) to be installed.

                          1. Unfortunately, possibly the ODBC plugin on Qt should be rebuilt:

                          Note: If you are using the prebuilt Qt libraries, you will need to download sources using MaintenanceTool ($QTDIR/MaintenanceTool.app)

                          • Tell qmake where to find the unixODBC header files and shared libraries (here it is assumed that unixODBC is installed in /usr/local/unixODBC) and run make:
                          cd $QTDIR/qtbase/src/plugins/sqldrivers/odbc
                          

                          my case:

                          cd /usr/local/Qt/5.9.1/Src/qtbase/src/plugins/sqldrivers/odbc
                          
                          qmake "INCLUDEPATH+=/usr/local/unixODBC/include" "LIBS+=-L/usr/local/unixODBC/lib -lodbc"
                          make
                          

                          if that goes correctly: you will get complied QODBC new libs:

                          cd ../plugins/sqldrivers/
                          

                          copy the new packages for example to :

                          /usr/local/Qt/5.9.1/clang_64/plugins/sqldrivers/
                          
                          1. Configure /etc/local/unixODBC/etc/odbc.ini (you might need root permissions to mdify)
                            (No need to configure freeTDS):

                          (which port ? which version -> Run /usr/local/freeTDS/bin/tsql -LH 192.168.x.x
                          Create/Modify entry in /usr/local/unixODBC/etc/odbc.ini

                          [MYDSN]
                          
                          Driver = /usr/local/freeTDS/lib/libtdsodbc.0.so
                          
                          Server = 192.168.x.x
                          
                          Port = 51271
                          
                          1. In Qt project:
                          QSqlDatabase mydb = QSqlDatabase::addDatabase("QODBC");
                          
                          mydb.setDatabaseName("MYDSN")
                          
                          mydb.setUserName("name on Database");
                          
                          mydb.setPassword(" password on Database");
                          mydb.open()
                          

                          (Luck && !alas) = true.

                          1 Reply Last reply
                          2
                          • J Offline
                            J Offline
                            julrich
                            wrote on last edited by
                            #19

                            To make the plugin link against unixodbc, I had to replace -liodbc with -lodbc in the configure.json file in the sqldrivers directory before following the instructions in the documentation (done with Qt 5.12.3).

                            So the complete steps for me were:

                            $ brew install unixodbc
                            $ cd path/to/Qt/5.12.3/Src/qtbase/src/plugins/sqldrivers
                            $ sed -i -e 's/-liodbc/-lodbc/' configure.json
                            $ qmake -- ODBC_PREFIX=/usr/local/Cellar/unixodbc/2.3.7
                            $ make sub-odbc
                            $ cp plugins/sqldrivers/libqsqlodbc* path/to/Qt/5.12.3/plugins/sqldrivers
                            
                            O 1 Reply Last reply
                            5
                            • J julrich

                              To make the plugin link against unixodbc, I had to replace -liodbc with -lodbc in the configure.json file in the sqldrivers directory before following the instructions in the documentation (done with Qt 5.12.3).

                              So the complete steps for me were:

                              $ brew install unixodbc
                              $ cd path/to/Qt/5.12.3/Src/qtbase/src/plugins/sqldrivers
                              $ sed -i -e 's/-liodbc/-lodbc/' configure.json
                              $ qmake -- ODBC_PREFIX=/usr/local/Cellar/unixodbc/2.3.7
                              $ make sub-odbc
                              $ cp plugins/sqldrivers/libqsqlodbc* path/to/Qt/5.12.3/plugins/sqldrivers
                              
                              O Offline
                              O Offline
                              oxycoder
                              wrote on last edited by
                              #20

                              @julrich I have to login and thank you.
                              It works.

                              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