Linux 上安装Lua

 

$ wget http://www.lua.org/ftp/lua-5.2.3.tar.gz

$ tar zxf lua-5.2.3.tar.gz

$ cd lua-5.2.3

$ make linux test

 

报错:

/usr/lib/gcc/x86_64-neoshine-linux/4.1.2/../../../../lib64/libreadline.so: undefined reference to `PC'

/usr/lib/gcc/x86_64-neoshine-linux/4.1.2/../../../../lib64/libreadline.so: undefined reference to `tgetflag'

/usr/lib/gcc/x86_64-neoshine-linux/4.1.2/../../../../lib64/libreadline.so: undefined reference to `tgetent'

/usr/lib/gcc/x86_64-neoshine-linux/4.1.2/../../../../lib64/libreadline.so: undefined reference to `UP'

/usr/lib/gcc/x86_64-neoshine-linux/4.1.2/../../../../lib64/libreadline.so: undefined reference to `tputs'

/usr/lib/gcc/x86_64-neoshine-linux/4.1.2/../../../../lib64/libreadline.so: undefined reference to `tgoto'

/usr/lib/gcc/x86_64-neoshine-linux/4.1.2/../../../../lib64/libreadline.so: undefined reference to `tgetnum'

/usr/lib/gcc/x86_64-neoshine-linux/4.1.2/../../../../lib64/libreadline.so: undefined reference to `BC'

/usr/lib/gcc/x86_64-neoshine-linux/4.1.2/../../../../lib64/libreadline.so: undefined reference to `tgetstr'

 

 

修改${LUA_DIR}/src/Makefile中linux编译target=linux,在SYSLIBS变量中追加‘-lncurses’选项即可。如下:

105 linux:

106        $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline -lncurses"

 

安装ncurses-devel-5.5-24.20060715.x86_64.rpm

 

再编译安装make linux test

 

bash-3.2$ src/lua -v

Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio

bash-3.2$ src/lua -i

Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio

> print ("tset")

tset

 

成功啦!

LUA基本语法:http://www.yiibai.com/lua/lua_basic_syntax.html#