Installing LuaSQL

From FreeSWITCH Wiki
Jump to: navigation, search

It is also possible to use the FS ODBC support through freeswitch.Dbh, without installing LuaSQL

luasql.odbc

This procedure has been verified to work on CentOS 5.5 (64bit).

First compile Lua:

yum install readline-devel.x86_64
cd /usr/src/freeswitch/src/mod/languages/mod_lua/lua
make linux
cp lua /usr/bin
cp luac /usr/bin

Get LuaSQL:

cd /usr/src
wget http://luaforge.net/frs/download.php/2686/luasql-2.1.1.tar.gz
tar -zxvf luasql-2.1.1.tar.gz
cd luasql-2.1.1

Modify config:

cat > config <<EOF
# Driver (leave uncommented ONLY the line with the name of the driver)
#T= mysql
#T= oci8
T= odbc
#T= postgres
#T= sqlite
#T=sqlite3

# Installation directories

# Default prefix

PREFIX = /usr/local

# System's libraries directory (where binary libraries are installed)
LUA_LIBDIR= $(PREFIX)/lib/lua/5.1

# System's lua directory (where Lua libraries are installed)
LUA_DIR= $(PREFIX)/share/lua/5.1

# Lua includes directory
# This is an important change here, it compiles lua against the FS libraries 
# instead of the system libraries
#LUA_INC= $(PREFIX)/include
LUA_INC= /usr/src/freeswitch/src/mod/languages/mod_lua/lua

# Lua version number (first and second digits of target version)
LUA_VERSION_NUM= 501

# OS dependent
LIB_OPTION= -shared #for Linux
#LIB_OPTION= -bundle -undefined dynamic_lookup #for MacOS X

LIBNAME= $T.so
COMPAT_DIR= ../compat/src

# Compilation parameters
# Driver specific
######## MySQL
#DRIVER_LIBS= -L/usr/local/mysql/lib -lmysqlclient -lz
#DRIVER_INCS= -I/usr/local/mysql/include
######## Oracle OCI8
#DRIVER_LIBS= -L/home/oracle/OraHome1/lib -lz -lclntsh
#DRIVER_INCS= -I/home/oracle/OraHome1/rdbms/demo -I/home/oracle/OraHome1/rdbms/public
######## PostgreSQL
#DRIVER_LIBS= -L/usr/local/pgsql/lib -lpq
#DRIVER_INCS= -I/usr/local/pgsql/include
######## SQLite
#DRIVER_LIBS= -lsqlite
#DRIVER_INCS=
######## SQLite3 
#DRIVER_LIBS= -L/opt/local/lib -lsqlite3
#DRIVER_INCS= -I/opt/local/include
######## ODBC
DRIVER_LIBS= -L/usr/lib64 -lodbc
DRIVER_INCS= -DUNIXODBC -I/usr/include

WARN= -fPIC -Wall -Wmissing-prototypes -Wmissing-declarations -ansi -pedantic
INCS= -I$(LUA_INC)
CFLAGS= -O2 $(WARN) -I$(COMPAT_DIR) $(DRIVER_INCS) $(INCS) $(DEFS)
CC= gcc

# $Id: config,v 1.8 2007/10/27 22:55:27 carregal Exp $
EOF

Make and install (to /usr/local/lib/lua/5.1/luasql - necessary for FreeSWITCH):

make
make install