首页 > 代码库 > lua-5.2.3编译问题记录"libreadline.so: undefined reference to `PC'"
lua-5.2.3编译问题记录"libreadline.so: undefined reference to `PC'"
作者:zhanhailiang 日期:2014-10-21
[root@~/software]# cd lua-5.2.3 [root@~/software/lua-5.2.3]# make linux cd src && make linux 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"
此时又一次运行:
[root@~/software/lua-5.2.3]# make linux install cd src && make linux make[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.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
至此,lua-5.2.3成功安装:
[root@~/software/lua-5.2.3/src]# /usr/local/bin/lua -v Lua 5.2.3 Copyright (C) 1994-2013 Lua.org, PUC-Rio
lua-5.2.3编译问题记录"libreadline.so: undefined reference to `PC'"
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。