Important: Please read the Qt Code of Conduct -

Issue building ODBC plugin on Linux

  • Hi, all -

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

    I've already built the unixODBC found here:

    Note #1: this doesn't produce a file named "" but it does produce a file named "" 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
    g++ -Wl,--no-undefined -Wl,-O1 -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,\$ORIGIN/../../lib -Wl,-rpath,\$ORIGIN/../../lib -shared -o .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/' failed
    make: *** [../../../../plugins/sqldrivers/] Error 1

    Note 2: in the 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.

  • Lifetime Qt Champion

    @mzimmers said in issue building ODBC plugin on Linux:


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

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


    "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.

  • @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.

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




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

    It will then build successfully.

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

  • @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.

  • @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.

Log in to reply