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:
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.
This is the usual name for a library in a UNIX system.
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.