在CentOS 5.x 中安装Lua 5.2.3时遇到如下错误:
# make linux
gcc -o lua lua.o liblua.a -lm -Wl,-E -ldl -lreadline
/usr/lib/gcc/x86_64-RedHat-linux/4.1.2/../../../../lib64/libreadline.so:undefined reference to `PC’
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/libreadline.so: undefined reference to `tgetflag’
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/libreadline.so: undefined reference to `tgetent’
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/libreadline.so:undefined reference to `UP’
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/libreadline.so: undefined reference to `tputs’
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/libreadline.so: undefined reference to `tgoto’
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/libreadline.so:undefined reference to `tgetnum’
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/libreadline.so: undefined reference to `BC’
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/libreadline.so: undefined reference to `tgetstr’
collect2: ld returned 1exit status
make[2]:***[lua]Error1
make[2]:Leaving directory `/opt/soft_bak/lua-5.2.3/src’
make[1]: *** [linux] Error 2
make[1]: Leaving directory `/opt/soft_bak/lua-5.2.3/src’
make: *** [linux] Error 2
解决办法, 添加 MYLIBS=-lncurses
[root@db-172-16-3-39 lua-5.2.3]# make linux MYLIBS=-lncurses
cd src && make linux
make[1]: Entering directory `/opt/soft_bak/lua-5.2.3/src’
make all SYSCFLAGS=”-DLUA_USE_LINUX” SYSLIBS=”-Wl,-E -ldl -lreadline”
make[2]: Entering directory `/opt/soft_bak/lua-5.2.3/src’
gcc -o lua lua.o liblua.a -lm -Wl,-E -ldl -lreadline -lncurses
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 -lncurses
make[2]: Leaving directory `/opt/soft_bak/lua-5.2.3/src’
make[1]: Leaving directory `/opt/soft_bak/lua-5.2.3/src’
[root@db-172-16-3-39 lua-5.2.3]# make install
cd src && mkdir -p /usr/local/bin /usr/local/include /usr/local/lib /usr/local/man/man1 /usr/local/share/lua/5.2 /usr/local/lib/lua/5.2
cd src && install -p -m 0755 lua luac /usr/local/bin
cd src && install -p -m 0644 lua.h luaconf.h lualib.h lauxlib.h lua.hpp /usr/local/include
cd src && install -p -m 0644 liblua.a /usr/local/lib
cd doc && install -p -m 0644 lua.1 luac.1 /usr/local/man/man1
[root@db-172-16-3-39 lua-5.2.3]# make test
src/lua -v
Lua 5.2.3 Copyright (C) 1994-2013 Lua.org, PUC-Rio
Lua 语言 15 分钟快速入门 http://www.linuxidc.com/Linux/2013-06/86582.htm
Lua程序设计(第2版)中文 PDF http://www.linuxidc.com/Linux/2013-03/81833.htm
Lua程序设计(第二版)阅读笔记 http://www.linuxidc.com/Linux/2013-03/81834.htm
NetBSD 将支持用 Lua 脚本开发内核组件 http://www.linuxidc.com/Linux/2013-02/79527.htm
CentOS 编译安装 Lua LuaSocket http://www.linuxidc.com/Linux/2011-08/41105.htm
Programming In Lua 高清PDF中文版 http://www.linuxidc.com/Linux/2015-05/117362.htm
如何配置一套优雅的Lua开发环境 http://www.linuxidc.com/Linux/2015-10/124397.htm
Lua 的详细介绍:请点这里
Lua 的下载地址:请点这里
本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-12/126509.htm