一、安装readline
wget -c ftp://ftp.gnu.org/gnu/readline/readline-6.2.tar.gz
tar -zxvf readline-6.2.tar.gz
cd readline-6.2
./configure
make && make installl
二、 安装lua
进入官方站点(http://www.lua.org/download.html )下载最新的安装包。
wget -c http://www.lua.org/ftp/lua-5.2.0.tar.gz
tar zxvf lua-5.2.0.tar.gz
cd lua-5.2.0
make linux
make install
make[1]: Entering directory `/root/software/lua-5.2.3/src'
make all SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline"
make[2]: Entering directory `/root/software/lua-5.2.3/src'
gcc -o lua lua.o liblua.a -lm -Wl,-E -ldl -lreadline
/usr/local/lib/libreadline.so: undefined reference to `PC'
/usr/local/lib/libreadline.so: undefined reference to `tgetflag'
/usr/local/lib/libreadline.so: undefined reference to `tgetent'
/usr/local/lib/libreadline.so: undefined reference to `UP'
/usr/local/lib/libreadline.so: undefined reference to `tputs'
/usr/local/lib/libreadline.so: undefined reference to `tgoto'
/usr/local/lib/libreadline.so: undefined reference to `tgetnum'
/usr/local/lib/libreadline.so: undefined reference to `BC'
/usr/local/lib/libreadline.so: undefined reference to `tgetstr'
collect2: ld returned 1 exit status
make[2]: *** [lua] Error 1
make[2]: Leaving directory `/root/software/lua-5.2.3/src'
make[1]: *** [linux] Error 2
make[1]: Leaving directory `/root/software/lua-5.2.3/src'
make: *** [linux] Error 2
这是因为lua编译依赖readline库,readline库依赖ncurses库,但没有指定,就会出现“未定义的符合引用”错误。
解决方案是修改${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库:/usr/lib目录下
没有的话,进行安装:apt-get install libncurses5-dev
再次执行,没有错误
![](http://img.blog.itpub.net/blog/attachment/201602/26/30316686_1456470523yrpK.png?x-oss-process=style/bb)
补充:继续遇到问题
![](http://img.blog.itpub.net/blog/attachment/201602/26/30316686_1456472980DXZf.png?x-oss-process=style/bb)
查看一下lua依赖的库
![](http://img.blog.itpub.net/blog/attachment/201602/26/30316686_1456473032wwWl.png?x-oss-process=style/bb)
在usr/local/lib下查看下是否存在
![](http://img.blog.itpub.net/blog/attachment/201602/26/30316686_14564731818Aqd.png?x-oss-process=style/bb)
存在的,那怎么就没生效呢?解决方法如下:
把libgsmd.so.0 所在lib位置加入到/etc/ld.so.conf文件当中
只要在/etc/ld.so.conf中加入/usr/local/lib这一行,就可以解決此问题,不仅仅是对于libreadline.so.5,大部分的so都存在
这/usr/local/lib这个目录里面。
最后将/etc/ld.so.conf保存后,还要执行ldconfig 才会使更改生效
![](http://img.blog.itpub.net/blog/attachment/201602/26/30316686_14564733097nS0.png?x-oss-process=style/bb)
有任何问题或技术上的交流探讨,欢迎加我微信:yk2953
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30316686/viewspace-1995163/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/30316686/viewspace-1995163/