最近在用tcl,想着连接mysql,从网上查了一下发现用mysqltcl比较好,不过需要自己编译,使用过程遇上一些问题,因此就总结了一下。首先是先编译mysqltcl。说明一下,我的tcl是通过yum install tcl命令直接安装的,因此不同安装方式tcl路径可能有变化,例如如果是通过rpm安装的,请自行制定路径。
第一步 下载mysqltcl
进入http://www.xdobry.de/mysqltcl/下载mysqltcl
下载的时候可以使用wget工具直接下载到linux中,wget工具的使用就不在这篇文章内进行讲解了
下载完成后准备开始编译,注意,需要提前安装gcc,如果没有安装,请先使用
yum install gcc
进行安装
第二步
使用
tar xvf mysqltcl-3.05.tar.gz
将下载下来的mysqltcl-3.05.tar.gz解压
解压完成后进入mysqltcl-3.05目录
cd mysqltcl-3.05
执行./configure命令,发现提示
checking for Tcl configuration... configure: WARNING: Can't find Tcl configuration definitions
通过
whereis tcl
命令进行查看,再对搜索到的结果进行筛选,发现路径/usr/share/tcl8.5中有文件存在
使用
./configure --with-tcl=/usr/share/tcl8.5
发现提示checking for Tcl configuration... configure: error: /usr/share/tcl8.5 directory doesn't contain tclConfig.sh
使用
whereis tclConfig.sh
发现没有找到文件
使用
yum install tcl-devel tk-devel
命令安装完毕后,再次执行
whereis tclConfig.sh
发现结果为tclConfig: /usr/lib64/tclConfig.sh
使用
./configure --with-tcl=/usr/share/tcl8.5 --with-tcl=/usr/lib64/tclConfig.sh
命令后
发现又提示checking for mysql header... configure: error: Cannot find mysql.h in /usr/include/mysql use -with-mysql-include=?
使用
yum install mysql-devel
命令,安装完毕后执行
./configure --with-tcl=/usr/share/tcl8.5 --with-tcl=/usr/lib64/tclConfig.sh --with-mysql-lib=/usr/lib64/mysql
依次使用
make
make install
结束后使用ls命令,发现文件夹中已经存在libmysqltcl3.05.so文件,就代表成功了
第三步
使用
cd ..
命令回到上一层
将mysqltcl-3.05文件夹移动到/usr/share/tcl8.5文件夹中
cp -r mysqltcl-3.05 /usr/share/tcl8.5
到此编译mysqltcl就结束了