整体流程结构
otl用头文件otlv4.h来声明接口,具体实现在linux下是由unixODBC来实现;通过FreeTDS驱动最终调用MySQL的DBMS(个人观点)
要安装的软件及步骤
所以要安装的有unixODBC,FreeTDS
具体安装参考:http://wenku.baidu.com/view/89e9e711a2161479171128de.html(此文章里面的设置有问题,参考本文中的“关于odbcinst.ini和odbc.ini的说明一节”)
关于odbcinst.ini和odbc.ini的说明
参考:http://blog.chinaunix.net/uid-7240278-id-131816.html 这篇文章中提到了默认的odbcinst.ini的位置在/usr/local/etc,这是在安装unixODBC是产生的,可以通过odbcinst -j指令来查看其具体位置
However since beta 1.6 the location of the system files odbcinst.ini and odbc.ini are determined by the configure script. The default location is /usr/local/etc, and if a prefix is specified the location is {prefix}/etc. The location of the etc path can be broken out of the normal prefix tree by specifing --sysconfdir=DIR, so the following will expect the system files to be in the same location as pre 1.6 builds.
./configure --sysconfdir=/etc
这时候会出现用otl的C++代码去连接DNS可能会出现:
[unixODBC][Driver Manager]Data source name not found, and no default driver specified
按照:http://bbs.chinaunix.net/thread-588178-1-1.html的说法,是因为新版本的unixODBC默认目录在/usr/local/etc里面,而原来可能安装了一个老版本的,那个版本的odbc.ini等在/etc下面,而你配置的odbcinst其实在/usr/local/etc里面,你用命令行连接成功的也是这个里面的配置给你提供的。所以要把这里面的配置文件覆盖到/etc里面替换老的odbc.ini等。
这时候就可以执行你写的C++程序了
我还看过一篇文章,讲修改系统环境变量,让新的/usr/local/etc作为unixODBC使用的环境变量目录