1. 安装达梦8
官网下载, 按照官方文档进行安装即可.
2. 安装unixodbc
1> 下载odbc安装包 unixODBC-2.3.7pre.tar.gz
2> 解压
tar -xvf unixODBC-2.3.7pre.tar.gz
3> 编译
./configure -prefix /usr/local
make && make install
4> 查找配置
odbcinst -j
5> 修改配置/usr/local/etc/odbcinst.ini
[DM8 ODBC DRIVER]
Description = ODBC DRIVER FOR DM8
Driver = /dm8/bin/libdodbc.so
6> 修改配置/usr/local/etc/odbc.ini
[DM8]
Description = DM ODBC DSND
Driver = DM8 ODBC DRIVER
SERVER = localhost
UID = SIMDB
PWD = systemdba
TCP_PORT = 5236
3. 编译QT环境QODBC驱动
/opt/Qt5.9.6/5.9.6/Src/qtbase/src/plugins/sqldrivers/odbc
4. 报错
4.1 找不到qtsqldrivers-config.pri
解决措施:
step1. 修改/opt/Qt5.9.6/5.9.6/Src/qtbase/src/plugins/sqldrivers/qsqldriverbase.pri文件
QT = core core-private sql-private
# For QMAKE_USE in the parent projects.
#include($$shadowed($$PWD)/qtsqldrivers-config.pri)
include($$shadowed($$PWD)/configure.pri)
PLUGIN_TYPE = sqldrivers
load(qt_plugin)
DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII
step2. 修改odbc.pro文件, 注释掉QMAKE_USE += odbc
step3. 执行/opt/Qt5.9.6/5.9.6/gcc_64/bin/qmake “LIBS+=-L/usr/local/lib -lodbc”
step4. make
step5. 执行cp …/plugins/sqldrivers/libqsqlodbc.so /opt/Qt5.9.6/5.9.6/gcc_64/plugins/sqldrivers/
4.2 QODBC未加载, 但是提示QODBC avaiable
可能原因及解决措施:
1> 配置问题, 检查配置, 标红的地方需要一致
2> 可能是QODBC库依赖不全, ldd查看一下补全依赖即可!