lua-5.2.3编译问题记录"libreadline.so: undefined reference to `PC'"

Posted wzzkaifa

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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'"的主要内容,如果未能解决你的问题,请参考以下文章

Windows下使用第三方lua库

"Hello World " —— 深入理解程序从编译到执行

小胖说事31------iOS 真机编译错误"“XXX”的 iPod" and run "XXX" again, or if &

redis 编译安装问题记录

没有“glu.h”和“windows.h”,GLFW 无法编译

Mac Silicon M1 编译安装 PHP8 & Swoole4.6 ARM64 全过程记录