Issue building ODBC plugin on Linux
-
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:
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.
-
@mzimmers said in issue building ODBC plugin on Linux:
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.
-
@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
-std=c++1z
with
-std=c++11
Also, if building on RHEL 7 remove the -Wdate-time switch.
It will then build successfully.
-
@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.