遇到的问题如http://blog.codingnow.com/2012/01/lua_link_bug.html所示。
1、把lua编译成so,修改lua的Makefile
TO_LIB= liblua.a ==> TO_LIB= liblua.so liblua.a
修改src/Makefile
(1)添加LUA_SO= liblua.so
(2)ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) ===> ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) $(LUA_SO)
(2)${LUA_SO}: $(CORE_O) $(LIB_)
$(CC) -o $@ -shared $?
在/etc/ld.so.conf中加入一行
/usr/local/lib/
然后执行
/sbin/ldconfig
make
make install
2、编译luasql
在config中添加
DRIVER_LIBS= -L/usr/local/mysql/lib -lmysqlclient -lz ===>
DRIVER_LIBS= -L/usr/local/mysql/lib -lmysqlclient -lz /usr/local/lib/liblua.a
3、编译C程序
gcc test.c -g -ldl -llua -lm /usr/local/lib/liblua.a -o sql
1、把lua编译成so,修改lua的Makefile
TO_LIB= liblua.a ==> TO_LIB= liblua.so liblua.a
修改src/Makefile
(1)添加LUA_SO= liblua.so
(2)ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) ===> ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) $(LUA_SO)
(2)${LUA_SO}: $(CORE_O) $(LIB_)
$(CC) -o $@ -shared $?
在/etc/ld.so.conf中加入一行
/usr/local/lib/
然后执行
/sbin/ldconfig
make
make install
2、编译luasql
在config中添加
DRIVER_LIBS= -L/usr/local/mysql/lib -lmysqlclient -lz ===>
DRIVER_LIBS= -L/usr/local/mysql/lib -lmysqlclient -lz /usr/local/lib/liblua.a
3、编译C程序
gcc test.c -g -ldl -llua -lm /usr/local/lib/liblua.a -o sql