歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux編程 >> Linux編程

lua-5.2.3編譯問題記錄“libreadline.so: undefined reference to `PC”

[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 語言 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

Lua 的詳細介紹:請點這裡
Lua 的下載地址:請點這裡

Copyright © Linux教程網 All Rights Reserved