1.在官网下载
下载地址http://www.lua.org/download.html
2.上传到Linux
3.安装
[root@CentOS lua-5.2.3]# make Please do 'make PLATFORM' where PLATFORM is one of these: aix ansi bsd freebsd generic linux macosx mingw posix solaris See doc/readme.html for complete instructions.
[root@CentOS lua-5.2.3]# make linux cd src && make linux make[1]: Entering directory `/root/dblion/lua-5.2.3/src' make all SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline" make[2]: Entering directory `/root/dblion/lua-5.2.3/src' gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lapi.o lapi.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lcode.o lcode.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lctype.o lctype.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o ldebug.o ldebug.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o ldo.o ldo.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o ldump.o ldump.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lfunc.o lfunc.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lgc.o lgc.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o llex.o llex.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lmem.o lmem.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lobject.o lobject.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lopcodes.o lopcodes.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lparser.o lparser.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lstate.o lstate.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lstring.o lstring.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o ltable.o ltable.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o ltm.o ltm.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lundump.o lundump.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lvm.o lvm.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lzio.o lzio.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lauxlib.o lauxlib.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lbaselib.o lbaselib.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lbitlib.o lbitlib.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lcorolib.o lcorolib.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o ldblib.o ldblib.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o liolib.o liolib.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lmathlib.o lmathlib.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o loslib.o loslib.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lstrlib.o lstrlib.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o ltablib.o ltablib.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o loadlib.o loadlib.c gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o linit.o linit.c ar rcu liblua.a lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o lmathlib.o loslib.o lstrlib.o ltablib.o loadlib.o linit.o ranlib liblua.a gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lua.o lua.c lua.c:67:31: 错误:readline/readline.h:没有那个文件或目录 lua.c:68:30: 错误:readline/history.h:没有那个文件或目录 lua.c: 在函数‘pushline’中: lua.c:265: 警告:隐式声明函数‘readline’ lua.c:265: 警告:赋值时将整数赋给指针,未作类型转换 lua.c: 在函数‘loadline’中: lua.c:297: 警告:隐式声明函数‘add_history’ make[2]: *** [lua.o] 错误 1 make[2]: Leaving directory `/root/dblion/lua-5.2.3/src' make[1]: *** [linux] 错误 2 make[1]: Leaving directory `/root/dblion/lua-5.2.3/src' make: *** [linux] 错误 2 [root@CentOS lua-5.2.3]#
[root@CentOS lua-5.2.3]# whereis readline readline: [root@CentOS lua-5.2.3]# yum install readline-devel.i686 Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * extras: mirrors.yun-idc.com * updates: mirrors.btte.net Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package readline-devel.i686 0:6.0-4.el6 will be installed --> Processing Dependency: ncurses-devel for package: readline-devel-6.0-4.el6.i686 --> Processing Dependency: libreadline.so.6 for package: readline-devel-6.0-4.el6.i686 --> Processing Dependency: libhistory.so.6 for package: readline-devel-6.0-4.el6.i686 --> Running transaction check ---> Package ncurses-devel.x86_64 0:5.7-3.20090208.el6 will be installed ---> Package readline.i686 0:6.0-4.el6 will be installed --> Processing Dependency: libtinfo.so.5 for package: readline-6.0-4.el6.i686 --> Processing Dependency: libc.so.6(GLIBC_2.4) for package: readline-6.0-4.el6.i686 --> Running transaction check ---> Package glibc.i686 0:2.12-1.132.el6_5.2 will be installed --> Processing Dependency: libfreebl3.so(NSSRAWHASH_3.12.3) for package: glibc-2.12-1.132.el6_5.2.i686 --> Processing Dependency: libfreebl3.so for package: glibc-2.12-1.132.el6_5.2.i686 ---> Package ncurses-libs.i686 0:5.7-3.20090208.el6 will be installed --> Running transaction check ---> Package nss-softokn-freebl.i686 0:3.14.3-10.el6_5 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================ Package Arch Version Repository Size ============================================================================================================ Installing: readline-devel i686 6.0-4.el6 base 134 k Installing for dependencies: glibc i686 2.12-1.132.el6_5.2 updates 4.3 M ncurses-devel x86_64 5.7-3.20090208.el6 base 642 k ncurses-libs i686 5.7-3.20090208.el6 base 251 k nss-softokn-freebl i686 3.14.3-10.el6_5 updates 147 k readline i686 6.0-4.el6 base 176 k Transaction Summary ============================================================================================================ Install 6 Package(s) Total download size: 5.7 M Installed size: 17 M Is this ok [y/N]: y Downloading Packages: (1/6): glibc-2.12-1.132.el6_5.2.i686.rpm | 4.3 MB 00:02 (2/6): ncurses-devel-5.7-3.20090208.el6.x86_64.rpm | 642 kB 00:00 (3/6): ncurses-libs-5.7-3.20090208.el6.i686.rpm | 251 kB 00:00 (4/6): nss-softokn-freebl-3.14.3-10.el6_5.i686.rpm | 147 kB 00:00 (5/6): readline-6.0-4.el6.i686.rpm | 176 kB 00:00 (6/6): readline-devel-6.0-4.el6.i686.rpm | 134 kB 00:00 ------------------------------------------------------------------------------------------------------------ Total 776 kB/s | 5.7 MB 00:07 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : glibc-2.12-1.132.el6_5.2.i686 1/6 Installing : nss-softokn-freebl-3.14.3-10.el6_5.i686 2/6 Installing : ncurses-libs-5.7-3.20090208.el6.i686 3/6 Installing : ncurses-devel-5.7-3.20090208.el6.x86_64 4/6 Installing : readline-6.0-4.el6.i686 5/6 Installing : readline-devel-6.0-4.el6.i686 6/6 Verifying : ncurses-libs-5.7-3.20090208.el6.i686 1/6 Verifying : nss-softokn-freebl-3.14.3-10.el6_5.i686 2/6 Verifying : readline-6.0-4.el6.i686 3/6 Verifying : readline-devel-6.0-4.el6.i686 4/6 Verifying : ncurses-devel-5.7-3.20090208.el6.x86_64 5/6 Verifying : glibc-2.12-1.132.el6_5.2.i686 6/6 Installed: readline-devel.i686 0:6.0-4.el6 Dependency Installed: glibc.i686 0:2.12-1.132.el6_5.2 ncurses-devel.x86_64 0:5.7-3.20090208.el6 ncurses-libs.i686 0:5.7-3.20090208.el6 nss-softokn-freebl.i686 0:3.14.3-10.el6_5 readline.i686 0:6.0-4.el6 Complete!
[root@CentOS lua-5.2.3]# make linux cd src && make linux make[1]: Entering directory `/root/upload/lua-5.2.3/src' make all SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline" make[2]: Entering directory `/root/upload/lua-5.2.3/src' gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lua.o lua.c gcc -o lua lua.o liblua.a -lm -Wl,-E -ldl -lreadline /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../libreadline.so when searching for -lreadline /usr/bin/ld: skipping incompatible /usr/lib/libreadline.so when searching for -lreadline /usr/bin/ld: cannot find -lreadline collect2: ld 返回 1 make[2]: *** [lua] 错误 1 make[2]: Leaving directory `/root/upload/lua-5.2.3/src' make[1]: *** [linux] 错误 2 make[1]: Leaving directory `/root/upload/lua-5.2.3/src' make: *** [linux] 错误 2 [root@CentOS lua-5.2.3]#
[root@CentOS local]# mkdir lua [root@CentOS local]# ls bin etc games include lib lib64 libexec lua net-snmp sbin scripts sedscript share src [root@CentOS local]# cd lua/ [root@CentOS lua]# pwd /usr/local/lua [root@CentOS lua-5.2.3]# vi Makefile 1 # Makefile for installing Lua 2 # See doc/readme.html for installation and customization instructions. 3 4 # == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= 5 6 # Your platform. See PLATS for possible values. 7 PLAT= none 8 9 # Where to install. The installation starts in the src and doc directories, 10 # so take care if INSTALL_TOP is not an absolute path. See the local target. 11 # You may want to make INSTALL_LMOD and INSTALL_CMOD consistent with 12 # LUA_ROOT, LUA_LDIR, and LUA_CDIR in luaconf.h. 13 INSTALL_TOP= /usr/local/lua --------------------添加lua 14 INSTALL_BIN= $(INSTALL_TOP)/bin 15 INSTALL_INC= $(INSTALL_TOP)/include 16 INSTALL_LIB= $(INSTALL_TOP)/lib 17 INSTALL_MAN= $(INSTALL_TOP)/man/man1 18 INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V 19 INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V 20 21 # How to install. If your install program does not support "-p", then 22 # you may have to run ranlib on the installed liblua.a. 23 INSTALL= install -p 24 INSTALL_EXEC= $(INSTALL) -m 0755 25 INSTALL_DATA= $(INSTALL) -m 0644 26 # 27 # If you don't have "install" you can use "cp" instead. 28 # INSTALL= cp -p 29 # INSTALL_EXEC= $(INSTALL) 30 # INSTALL_DATA= $(INSTALL)
注意:如果遇到make linux或者make install报错,先运行 [root@CentOS lua-5.2.3]# yum install -y readline-devel ncurses-devel Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirror.bit.edu.cn * extras: mirror.bit.edu.cn * updates: mirror.bit.edu.cn Setting up Install Process Package ncurses-devel-5.7-3.20090208.el6.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package readline-devel.x86_64 0:6.0-4.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================ Package Arch Version Repository Size ============================================================================================================ Installing: readline-devel x86_64 6.0-4.el6 base 134 k Transaction Summary ============================================================================================================ Install 1 Package(s) Total download size: 134 k Installed size: 255 k Downloading Packages: y readline-devel-6.0-4.el6.x86_64.rpm | 134 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : readline-devel-6.0-4.el6.x86_64 1/1 Verifying : readline-devel-6.0-4.el6.x86_64 1/1 Installed: readline-devel.x86_64 0:6.0-4.el6 Complete!
[root@CentOS lua-5.2.3]# make linux cd src && make linux make[1]: Entering directory `/root/upload/lua-5.2.3/src' make all SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline" make[2]: Entering directory `/root/upload/lua-5.2.3/src' gcc -o lua lua.o liblua.a -lm -Wl,-E -ldl -lreadline gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o luac.o luac.c gcc -o luac luac.o liblua.a -lm -Wl,-E -ldl -lreadline make[2]: Leaving directory `/root/upload/lua-5.2.3/src' make[1]: Leaving directory `/root/upload/lua-5.2.3/src'
[root@CentOS testscripts]# cat dblion.lua print("dblion test") [root@CentOS testscripts]# lua dblion.lua dblion test