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. Using system ODBC library with Qt
Forum Updated to NodeBB v4.3 + New Features

Using system ODBC library with Qt

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 577 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.
  • G Offline
    G Offline
    gdlaird
    wrote on last edited by
    #1

    Hello,
    I have a large software package that uses ODBC version 3.5 calls to query a mysql database server. The database does not use the Qt database framework--it uses just the bare ODBC function calls. The software was developed on linux in the eclipse IDE and it works fine. The ODBC function calls require the system ODBC library libodbc.

    I have been trying to get this ODBC code base to work in a Qt environment. When I include the system odbc library in the Qt .pro file, the software complies without error but I end up having strange run-time errors.
    The .pro file has this line to add the odbc library while building the application.
    ...
    LIBS += -L/usr/lib64 -lodbc
    ...

    Using Qt 6.6 I get the following errors when starting the application:
    /home/glaird/workspaceQt/BO_DB_Write_Exec/BO_DB_Write_Exec: /usr/lib64/libQt6Core.so.6: version Qt_6.6' not found (required by /home/glaird/workspaceQt/BO_DB_Write_Exec/BO_DB_Write_Exec) /home/glaird/workspaceQt/BO_DB_Write_Exec/BO_DB_Write_Exec: /usr/lib64/libQt6Core.so.6: version Qt_6.2.2_PRIVATE_API' not found (required by /usr/lib64/libQt6Gui.so.6)
    /home/glaird/workspaceQt/BO_DB_Write_Exec/BO_DB_Write_Exec: /usr/lib64/libQt6Core.so.6: version `Qt_6.2.2_PRIVATE_API' not found (required by /usr/lib64/libQt6DBus.so.6)

    If I try Qt 5.15 I get this error at runtime:
    /home/glaird/workspaceQt/BO_DB_Write_Exec/BO_DB_Write_Exec: symbol lookup error: /home/glaird/workspaceQt/BO_DB_Write_Exec/BO_DB_Write_Exec: undefined symbol: _ZdlPvm, version Qt_5

    I find that if I add the libobdc library to any Qt application I get these same sort of strange errors.

    It looks to me like I have some symbol collisions between the Qt libraries and the odbc library. I am not sure what to do?

    Anyone have suggestions. Thanks!

    jsulmJ 1 Reply Last reply
    0
    • G gdlaird

      Hello,
      I have a large software package that uses ODBC version 3.5 calls to query a mysql database server. The database does not use the Qt database framework--it uses just the bare ODBC function calls. The software was developed on linux in the eclipse IDE and it works fine. The ODBC function calls require the system ODBC library libodbc.

      I have been trying to get this ODBC code base to work in a Qt environment. When I include the system odbc library in the Qt .pro file, the software complies without error but I end up having strange run-time errors.
      The .pro file has this line to add the odbc library while building the application.
      ...
      LIBS += -L/usr/lib64 -lodbc
      ...

      Using Qt 6.6 I get the following errors when starting the application:
      /home/glaird/workspaceQt/BO_DB_Write_Exec/BO_DB_Write_Exec: /usr/lib64/libQt6Core.so.6: version Qt_6.6' not found (required by /home/glaird/workspaceQt/BO_DB_Write_Exec/BO_DB_Write_Exec) /home/glaird/workspaceQt/BO_DB_Write_Exec/BO_DB_Write_Exec: /usr/lib64/libQt6Core.so.6: version Qt_6.2.2_PRIVATE_API' not found (required by /usr/lib64/libQt6Gui.so.6)
      /home/glaird/workspaceQt/BO_DB_Write_Exec/BO_DB_Write_Exec: /usr/lib64/libQt6Core.so.6: version `Qt_6.2.2_PRIVATE_API' not found (required by /usr/lib64/libQt6DBus.so.6)

      If I try Qt 5.15 I get this error at runtime:
      /home/glaird/workspaceQt/BO_DB_Write_Exec/BO_DB_Write_Exec: symbol lookup error: /home/glaird/workspaceQt/BO_DB_Write_Exec/BO_DB_Write_Exec: undefined symbol: _ZdlPvm, version Qt_5

      I find that if I add the libobdc library to any Qt application I get these same sort of strange errors.

      It looks to me like I have some symbol collisions between the Qt libraries and the odbc library. I am not sure what to do?

      Anyone have suggestions. Thanks!

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

      @gdlaird said in Using system ODBC library with Qt:

      I find that if I add the libobdc library to any Qt application I get these same sort of strange errors

      Do you mean you can build Qt application if you do not add libodbc?

      How did you install Qt? You seem to have Qt installed in /usr/lib64.

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

      G 1 Reply Last reply
      0
      • jsulmJ jsulm

        @gdlaird said in Using system ODBC library with Qt:

        I find that if I add the libobdc library to any Qt application I get these same sort of strange errors

        Do you mean you can build Qt application if you do not add libodbc?

        How did you install Qt? You seem to have Qt installed in /usr/lib64.

        G Offline
        G Offline
        gdlaird
        wrote on last edited by
        #3

        @jsulm What I meant was that I could take a non-ODBC Qt application and add the "LIBS += -L/usr/lib64 -lodbc" line to the .pro file, I will then get these strange run-time errors. I did this to see what would happen as a test--I would think that if an application ODBC calls, adding the library shouldn't make any difference--but it does.

        Qt 5.15 is installed in /usr/local/Qt and Qt 6.3,6.6 are installed in /usr/local/Qt6.

        I have many other Qt applications and they work fine with both Qt 5 & 6. I have tried to take as many Qt system elements out of the faulty application. There are no QObject, QThread, etc. I am using boost for threading and asio for socket communication.

        The problem seems to be somewhat intermittent; with Qt 5 I can run debug and single step into the program using gdb a ways and then it will crash when I try to delete (correctly) an object that had been allocated. Other times, I can't even get the application to start without the error. So, there is some sort of interaction between Qt libraries and libodbc.

        To be clear, I cannot get the application to compile and link without the odbc library.

        Here is the .pro file I am using:
        CONFIG += c++17
        CONFIG -= app_bundle

        QMAKE_CXX = g++-9
        QMAKE_CXXFLAGS += -std=c++0x -pthread

        You can make your code fail to compile if it uses deprecated APIs.

        In order to do so, uncomment the following line.

        #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

        SOURCES +=
        ../MS_ClassLib/sheet_defs.cpp
        ../MS_ClassLib/message_base.cpp
        ../MS_ClassLib/mesid_bo_db_write.cpp
        main.cpp
        DB_Rtns/BOD_DBRtns.cpp
        DB_Rtns/BOD_DBTables.cpp
        DB_Rtns/GameNormalize.cpp
        DB_Rtns/ODBC_Database.cpp
        DB_Rtns/ODBC_Objects.cpp
        DB_Rtns/ODBC_Tables.cpp
        DB_Rtns/dbproc.cpp
        socketio.cpp

        HEADERS +=
        DB_Rtns/BOD_DBTables.h
        DB_Rtns/GameNormalize.h
        DB_Rtns/ODBC_Database.h
        DB_Rtns/ODBC_Objects.h
        DB_Rtns/ODBC_Tables.h
        ../MS_ClassLib/sheet_defs.h
        ../MS_ClassLib/MS_Defs.h
        ../MS_ClassLib/message_base.h
        ../MS_ClassLib/mesid_bo_db_write.h
        DB_Rtns/dbproc.h

        LD_LIBRARY_PATH=/usr/lib64

        LIBS += -L/usr/local/lib -lboost_thread
        LIBS += -L/usr/local/lib -lboost_chrono
        LIBS += -L/usr/lib64 -lodbc
        LIBS += -pthread

        INCLUDEPATH += /usr/local/asio/include
        INCLUDEPATH += /usr/local/boost

        DEPENDPATH += /usr/local/boost
        DEPENDPATH += /usr/lib64
        DEPENDPATH += /usr/local/boost/lib

        DESTDIR = ../BO_DB_Write_Exec
        TARGET = BO_DB_Write_Exec

        G 1 Reply Last reply
        0
        • G gdlaird

          @jsulm What I meant was that I could take a non-ODBC Qt application and add the "LIBS += -L/usr/lib64 -lodbc" line to the .pro file, I will then get these strange run-time errors. I did this to see what would happen as a test--I would think that if an application ODBC calls, adding the library shouldn't make any difference--but it does.

          Qt 5.15 is installed in /usr/local/Qt and Qt 6.3,6.6 are installed in /usr/local/Qt6.

          I have many other Qt applications and they work fine with both Qt 5 & 6. I have tried to take as many Qt system elements out of the faulty application. There are no QObject, QThread, etc. I am using boost for threading and asio for socket communication.

          The problem seems to be somewhat intermittent; with Qt 5 I can run debug and single step into the program using gdb a ways and then it will crash when I try to delete (correctly) an object that had been allocated. Other times, I can't even get the application to start without the error. So, there is some sort of interaction between Qt libraries and libodbc.

          To be clear, I cannot get the application to compile and link without the odbc library.

          Here is the .pro file I am using:
          CONFIG += c++17
          CONFIG -= app_bundle

          QMAKE_CXX = g++-9
          QMAKE_CXXFLAGS += -std=c++0x -pthread

          You can make your code fail to compile if it uses deprecated APIs.

          In order to do so, uncomment the following line.

          #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

          SOURCES +=
          ../MS_ClassLib/sheet_defs.cpp
          ../MS_ClassLib/message_base.cpp
          ../MS_ClassLib/mesid_bo_db_write.cpp
          main.cpp
          DB_Rtns/BOD_DBRtns.cpp
          DB_Rtns/BOD_DBTables.cpp
          DB_Rtns/GameNormalize.cpp
          DB_Rtns/ODBC_Database.cpp
          DB_Rtns/ODBC_Objects.cpp
          DB_Rtns/ODBC_Tables.cpp
          DB_Rtns/dbproc.cpp
          socketio.cpp

          HEADERS +=
          DB_Rtns/BOD_DBTables.h
          DB_Rtns/GameNormalize.h
          DB_Rtns/ODBC_Database.h
          DB_Rtns/ODBC_Objects.h
          DB_Rtns/ODBC_Tables.h
          ../MS_ClassLib/sheet_defs.h
          ../MS_ClassLib/MS_Defs.h
          ../MS_ClassLib/message_base.h
          ../MS_ClassLib/mesid_bo_db_write.h
          DB_Rtns/dbproc.h

          LD_LIBRARY_PATH=/usr/lib64

          LIBS += -L/usr/local/lib -lboost_thread
          LIBS += -L/usr/local/lib -lboost_chrono
          LIBS += -L/usr/lib64 -lodbc
          LIBS += -pthread

          INCLUDEPATH += /usr/local/asio/include
          INCLUDEPATH += /usr/local/boost

          DEPENDPATH += /usr/local/boost
          DEPENDPATH += /usr/lib64
          DEPENDPATH += /usr/local/boost/lib

          DESTDIR = ../BO_DB_Write_Exec
          TARGET = BO_DB_Write_Exec

          G Offline
          G Offline
          gdlaird
          wrote on last edited by
          #4

          @gdlaird "-I would think that if an application ODBC calls" should be
          "-I would think that if an application has no ODBC calls"

          Christian EhrlicherC 1 Reply Last reply
          0
          • G gdlaird

            @gdlaird "-I would think that if an application ODBC calls" should be
            "-I would think that if an application has no ODBC calls"

            Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            It looks like you're mixing different Qt versions. I would guess you have a system Qt installation in /usr/lib64 and a custom one (e.g. installed via the Qt online installer) somewhere else. Now the problem is that when you execute your application, also the Qt libs from /usr/lib64 are used which have the wrong version.

            You have two options

            • move the odbc lib to another location (e.g. create symlink in /usr/local/lib64 and link against them there
            • use the sytem-wide Qt installation instead the one from the Qt online installer

            No Qt specific problem but one you get as soon as you have a library with more than one version on your system. I would give the first option a try.

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

            G 1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              It looks like you're mixing different Qt versions. I would guess you have a system Qt installation in /usr/lib64 and a custom one (e.g. installed via the Qt online installer) somewhere else. Now the problem is that when you execute your application, also the Qt libs from /usr/lib64 are used which have the wrong version.

              You have two options

              • move the odbc lib to another location (e.g. create symlink in /usr/local/lib64 and link against them there
              • use the sytem-wide Qt installation instead the one from the Qt online installer

              No Qt specific problem but one you get as soon as you have a library with more than one version on your system. I would give the first option a try.

              G Offline
              G Offline
              gdlaird
              wrote on last edited by
              #6

              @Christian-Ehrlicher That was exactly the problem. Thank you so much!

              1 Reply Last reply
              0
              • G gdlaird has marked this topic as solved on

              • Login

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