Zhanhailiang Date: 2014-10-21
[root@~/software]# cd lua-5.2.3[root@~/software/lua-5.2.3]# make linuxcd src && make linuxmake[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 statusmake[2]: *** [lua] Error 1make[2]: Leaving directory `/root/software/lua-5.2.3/src‘make[1]: *** [linux] Error 2make[1]: Leaving directory `/root/software/lua-5.2.3/src‘make: *** [linux] Error 2
This is becauseLuaCompile DependenciesReadlineLibrary and Readline library dependencyNcursesLibrary, but not specified, the "undefined reference compliance" error will occur.
Solution: Modify $ {lua_dir }/Src/makefileCompiling in LinuxTarget = Linux, InSyslibsAppend in variable'-Lncurses'Option. As follows:
105 linux:106 $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline -lncurses"
Execute again:
[root@~/software/lua-5.2.3]# make linux installcd src && make linuxmake[1]: Entering directory `/root/software/lua-5.2.3/src‘make all SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline -lncurses"make[2]: Entering directory `/root/software/lua-5.2.3/src‘make[2]: Nothing to be done for `all‘.make[2]: Leaving directory `/root/software/lua-5.2.3/src‘make[1]: Leaving directory `/root/software/lua-5.2.3/src‘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.2cd src && install -p -m 0755 lua luac /usr/local/bincd src && install -p -m 0644 lua.h luaconf.h lualib.h lauxlib.h lua.hpp /usr/local/includecd src && install -p -m 0644 liblua.a /usr/local/libcd doc && install -p -m 0644 lua.1 luac.1 /usr/local/man/man1
So far, lua-5.2.3 installation successful:
[root@~/software/lua-5.2.3/src]# /usr/local/bin/lua -vLua 5.2.3 Copyright (C) 1994-2013 Lua.org, PUC-Rio
Lua-5.2.3 compilation problem "/usr/local/lib/libreadline. So: Undefined reference to 'pc '"