关闭

编译lua5.3.3

标签: lua
487人阅读 评论(0) 收藏 举报

1、下载lua最新的库并解压:

https://www.lua.org/download.html

#tar -zxf  lua-5.3.3.tar.gz

2、下载readline库并解压编译,因为lua.c引用了readline库

下载地址:ftp://ftp.gnu.org/gnu/readline/

#tar -zxf readline-6.3.tar.gz

#cd readline-6.3

#./configure --prefix=/home/XX/Desktop/lua-5.3.3/out && make && make install

3、修改lua-5.3.3/src/Makefile下面两行

CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS) -I/home/XX/Desktop/lua-5.3.3/out/include
LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS)  -L/home/XX/Desktop/lua-5.3.3/out/lib


gcc -std=gnu99 -o lua    -L/home/wifi/Desktop/lua-5.3.3/out/lib lua.o liblua.a -lm -Wl,-E -ldl -lreadline 
/home/XX/Desktop/lua-5.3.3/out/lib/libreadline.so: undefined reference to `tputs'
/home/XX/Desktop/lua-5.3.3/out/lib/libreadline.so: undefined reference to `tgoto'
/home/XX/Desktop/lua-5.3.3/out/lib/libreadline.so: undefined reference to `tgetflag'
/home/XX/Desktop/lua-5.3.3/out/lib/libreadline.so: undefined reference to `UP'
/home/XX/Desktop/lua-5.3.3/out/lib/libreadline.so: undefined reference to `tgetent'
/home/XX/Desktop/lua-5.3.3/out/lib/libreadline.so: undefined reference to `tgetnum'
/home/XX/Desktop/lua-5.3.3/out/lib/libreadline.so: undefined reference to `PC'
/home/XX/Desktop/lua-5.3.3/out/lib/libreadline.so: undefined reference to `tgetstr'
/home/XX/Desktop/lua-5.3.3/out/lib/libreadline.so: undefined reference to `BC'
collect2: error: ld returned 1 exit status
Makefile:64: recipe for target 'lua' failed
make[2]: *** [lua] Error 1


报这个错是因为lua 依赖readline,而readline依赖ncurses,但没有指定,就会出现“未定义的符合引用”错误。

解决方案是修改${LUA_DIR}/src/Makefile中linux编译target=linux,在SYSLIBS变量中追加‘-lncurses’选项即可。如下:

linux:
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline -lncurses"


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:323678次
    • 积分:3548
    • 等级:
    • 排名:第9635名
    • 原创:54篇
    • 转载:28篇
    • 译文:1篇
    • 评论:37条
    最新评论