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. Issue building ODBC plugin on Linux

Issue building ODBC plugin on Linux

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 3.3k 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by A Former User
    #1

    Hi, all -

    I'm trying to build the ODBC plugin for Linux, per the instructions on the page:

    http://doc.qt.io/qt-5.8/sql-driver.html#qodbc

    I've already built the unixODBC found here:

    http://www.unixodbc.org/

    Note #1: this doesn't produce a file named "odbc.so" but it does produce a file named "libodbc.so" which I'm assuming is a new name. Bad assumption?

    So, qmake runs with this command, but make says it can't find the library.

    root@debian:/opt/Qt/5.8/Src/qtbase/src/plugins/sqldrivers/odbc# /opt/Qt/5.8/gcc_64/bin/qmake "INCLUDEPATH+=/usr/local/unixODBC-2.3.4/include" "LIBS+=-L/usr/local/lib -llibodbc"
    root@debian:/opt/Qt/5.8/Src/qtbase/src/plugins/sqldrivers/odbc# make
    rm -f libqsqlodbc.so
    g++ -Wl,--no-undefined -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,\$ORIGIN/../../lib -Wl,-rpath,\$ORIGIN/../../lib -shared -o libqsqlodbc.so .obj/qsql_odbc.o .obj/main.o .obj/moc_qsql_odbc_p.o  -L/usr/local/lib -llibodbc -L/opt/Qt/5.8/gcc_64/lib -lQt5Sql -lQt5Core -lpthread  
    /usr/bin/ld: cannot find -llibodbc
    collect2: error: ld returned 1 exit status
    Makefile:117: recipe for target '../../../../plugins/sqldrivers/libqsqlodbc.so' failed
    make: *** [../../../../plugins/sqldrivers/libqsqlodbc.so] Error 1
    root@debian:/opt/Qt/5.8/Src/qtbase/src/plugins/sqldrivers/odbc# 
    

    Note 2: in the odbc.pro file, I commented out a line QMAKE_USE += odbc in order to get rid of a qmake error:

    Project ERROR: Library 'odbc' is not defined.
    

    Any idea what I'm doing wrong here? Thanks.

    jsulmJ 1 Reply Last reply
    0
    • mzimmersM mzimmers

      Hi, all -

      I'm trying to build the ODBC plugin for Linux, per the instructions on the page:

      http://doc.qt.io/qt-5.8/sql-driver.html#qodbc

      I've already built the unixODBC found here:

      http://www.unixodbc.org/

      Note #1: this doesn't produce a file named "odbc.so" but it does produce a file named "libodbc.so" which I'm assuming is a new name. Bad assumption?

      So, qmake runs with this command, but make says it can't find the library.

      root@debian:/opt/Qt/5.8/Src/qtbase/src/plugins/sqldrivers/odbc# /opt/Qt/5.8/gcc_64/bin/qmake "INCLUDEPATH+=/usr/local/unixODBC-2.3.4/include" "LIBS+=-L/usr/local/lib -llibodbc"
      root@debian:/opt/Qt/5.8/Src/qtbase/src/plugins/sqldrivers/odbc# make
      rm -f libqsqlodbc.so
      g++ -Wl,--no-undefined -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,\$ORIGIN/../../lib -Wl,-rpath,\$ORIGIN/../../lib -shared -o libqsqlodbc.so .obj/qsql_odbc.o .obj/main.o .obj/moc_qsql_odbc_p.o  -L/usr/local/lib -llibodbc -L/opt/Qt/5.8/gcc_64/lib -lQt5Sql -lQt5Core -lpthread  
      /usr/bin/ld: cannot find -llibodbc
      collect2: error: ld returned 1 exit status
      Makefile:117: recipe for target '../../../../plugins/sqldrivers/libqsqlodbc.so' failed
      make: *** [../../../../plugins/sqldrivers/libqsqlodbc.so] Error 1
      root@debian:/opt/Qt/5.8/Src/qtbase/src/plugins/sqldrivers/odbc# 
      

      Note 2: in the odbc.pro file, I commented out a line QMAKE_USE += odbc in order to get rid of a qmake error:

      Project ERROR: Library 'odbc' is not defined.
      

      Any idea what I'm doing wrong here? Thanks.

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

      @mzimmers said in issue building ODBC plugin on Linux:

      "libodbc.so"

      This is the usual name for a library in a UNIX system.
      Change

      "LIBS+=-L/usr/local/lib -llibodbc"
      

      to

      "LIBS+=-L/usr/local/lib -lodbc"
      

      Explanation: when using -l you need to omit lib prefix - it is added automatically when searching for the lib.

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

      mzimmersM 1 Reply Last reply
      2
      • jsulmJ jsulm

        @mzimmers said in issue building ODBC plugin on Linux:

        "libodbc.so"

        This is the usual name for a library in a UNIX system.
        Change

        "LIBS+=-L/usr/local/lib -llibodbc"
        

        to

        "LIBS+=-L/usr/local/lib -lodbc"
        

        Explanation: when using -l you need to omit lib prefix - it is added automatically when searching for the lib.

        mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #3

        @jsulm thank you. That appears to be the solution.

        As a sidenote, I'm experiencing the same minor issue with this build as I was with the MySQL plugin: the produced Makefiles have the compiler flag "-std=c++1z" set, and I don't know how to get rid of it other than manually editing the Makefile.

        Thanks for the help.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          coquetangler
          wrote on last edited by
          #4

          For anyone else who encounters this. You need to edit the Makefile and replace

          -std=c++1z

          with

          -std=c++11

          Also, if building on RHEL 7 remove the -Wdate-time switch.

          It will then build successfully.

          1 Reply Last reply
          1
          • mzimmersM Offline
            mzimmersM Offline
            mzimmers
            wrote on last edited by
            #5

            Yes, that works. I was hoping that someone might have an idea on why that flag gets generated, and how to prevent it.

            C 1 Reply Last reply
            0
            • mzimmersM mzimmers

              Yes, that works. I was hoping that someone might have an idea on why that flag gets generated, and how to prevent it.

              C Offline
              C Offline
              coquetangler
              wrote on last edited by
              #6

              @mzimmers the --std=c++1z is for c++ 17. The z is used prior to the final specification been agreed. RHEL does not have c++ 17 which is why I changed it.

              mzimmersM 1 Reply Last reply
              0
              • C coquetangler

                @mzimmers the --std=c++1z is for c++ 17. The z is used prior to the final specification been agreed. RHEL does not have c++ 17 which is why I changed it.

                mzimmersM Offline
                mzimmersM Offline
                mzimmers
                wrote on last edited by
                #7

                @coquetangler I understand the meaning of the flag. What I don't understand is why this particular project is generating that flag, and how to prevent it. I would expect to be able to do this via the project file, rather than having to edit the makefile every time I run qmake, but I haven't found the answer yet.

                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