luamysql 安装

lua版本:lua-5.1.5,下载链接:http://www.lua.org/ftp/lua-5.1.5.tar.gz
luamysql版本:luasql-2.1.1,下载链接:http://files.luaforge.net/releases/luasql/luasql/LuaSQL2.1.1/luasql-2.1.1.tar.gz
系统:centos 6

1、下载lua5.1.5以及luamysql2.1.1

2、解压lua:tar zxvf lua-5.1.5.tar.gz

3、进入lua-5.1.5目录,安装:sudo make linux && make install,安装完成后,lua相关路径信息如下:

[zhangleifly@localhost mysql]$ whereis lua
lua: /usr/bin/lua /usr/lib/lua /usr/local/bin/lua /usr/local/lib/lua /usr/share/lua /usr/share/man/man1/lua.1.gz
4、解压luasql:tar zxvf  luasql-2.1.1.tar.gz

5、进入luasql目录,因为只需要对mysql的支持,因此对config文件进行修改,去掉T= mysql前面的注释,同时注释掉T= sqlite3,同时针对本机上mysql的安装路径信息修改以下信息:DRIVER_LIBS= -L/usr/lib/mysql -lmysqlclient -lz
DRIVER_INCS= -I/usr/include/mysql,可通过whereis mysql查看,例如我的机器是:

[zhangleifly@localhost www]$ whereis mysql
mysql: /usr/bin/mysql /usr/lib/mysql /usr/include/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

同时在WARN= -Wall -Wmissing-prototypes -Wmissing-declarations -ansi -pedantic 后面增加-Wno-long-long,否则可能出现错误:

In file included from src/ls_mysql.c:19:
/usr/include/mysql/mysql.h:130: 警告:ISO C90 不支持‘long long’

接下来执行安装:sudo make && make install,安装成功会看到:

mkdir -p /usr/local/lib/lua/5.1/luasql
cp src/mysql.so /usr/local/lib/lua/5.1/luasql

也就所说mysql.so现在以及存在与 /usr/local/lib/lua/5.1/luasql目录下的,当我们进行测试,可能会遇到错误:

stdin:1: module ‘luasql.mysql’ not found:
no field package.preload['luasql.mysql']
no file ‘./luasql/mysql.lua’
no file ‘/usr/share/lua/5.1/luasql/mysql.lua’
no file ‘/usr/share/lua/5.1/luasql/mysql/init.lua’
no file ‘/usr/lib/lua/5.1/luasql/mysql.lua’
no file ‘/usr/lib/lua/5.1/luasql/mysql/init.lua’
no file ‘./luasql/mysql.so’
no file ‘/usr/lib/lua/5.1/luasql/mysql.so’
no file ‘/usr/lib/lua/5.1/loadall.so’
no file ‘./luasql.so’
no file ‘/usr/lib/lua/5.1/luasql.so’
no file ‘/usr/lib/lua/5.1/loadall.so’

那我们就进入目录’/usr/lib/lua/5.1,建立文件夹luasql,并将mysql.so拷贝进来即可。

posted @ 2012-12-04 10:30  596448745  阅读(1583)  评论(0编辑  收藏  举报