解决在银河麒麟系统中使用Qt连接达梦数据库提示:project Error library odbc is not defined问题
一、编译ODBC
下载解压unixODBC(http://www.unixodbc.org/unixODBC-2.3.1.tar.gz)

打开终端,切换到unixODBC-2.3.1目录下,并输入:
./configure --prefix=/usr/local/unixODBC

在分别输入:
make
make install
在/usr/local/unixODBC/lib文件夹下生成如下文件,红框中的三个文件一个会用到

打开终端,切换到/home/watertk/Qt5.12.0/5.12.0/Src/qtbase/src/plugins/sqldrivers/odbc(注:/home/watertk/Qt5.12.0是Qt安装目录)
在终端中输入:
/home/watertk/Qt5.12.0/5.12.0/gcc_64/bin/qmake -makefile "INCLUDEPATH+=/usr/local/unixODBC/include" "LIBS+=-L/usr/local/unixODBC/lib -lodbc" odbc.pro

注:如果出现红框中的两个问题,请查看二、三小节
在odbc文件夹下会产生Makefile文件

在终端中分别执行:
make
make install
在Qt安装目录下/home/watertk/Qt5.12.0/5.12.0/gcc_64/plugins/sqldrivers会产出两个文件

Qt中运行如下代码,可以看到有ODBC的驱动,并打开数据库成功

二、提示:ldrivers-config.pri: No such file or directory
在Qt安装目录,如下图所示的文件夹中,更改qsqldriverbase.pri文件中的代码

把qtsqldrivers-config.pri改成configure.pri,保存文件,重新编译

三、提示:Project ERROR: Library 'odbc' is not defined.
把/usr/local/unixODBC/lib文件夹中的三个文件拷贝到
/home/watertk/Qt5.12.0/5.12.0/Src/qtbase/src/plugins/sqldrivers/odbc文件夹下

更改odbc.pro中的代码,保存文件,重新编译
#QMAKE_USE += odbc
QMAKE_LFLAGS += libodbc.so
