01、具体报错
mhzzj@mhzzj-virtual-machine:~/work/LuaCode/lua-5.3.0$ sudo make linux
[sudo] password for mhzzj:
cd src && make linux
make[1]: Entering directory '/home/mhzzj/work/LuaCode/lua-5.3.0/src'
make all SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline"
make[2]: Entering directory '/home/mhzzj/work/LuaCode/lua-5.3.0/src'
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_2 -DLUA_USE_LINUX -c -o lua.o lua.c
lua.c:80:10: fatal error: readline/readline.h: No such file or directory
80 | #include <readline/readline.h>
| ^~~~~~~~~~~~~~~~~~~~~
02、解决方案
安装readline:sudo apt install libreadline-dev
mhzzj@mhzzj-virtual-machine:~/work/LuaCode/lua-5.3.0$ sudo apt install libreadline-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libncurses-dev
Suggested packages:
ncurses-doc readline-doc
The following NEW packages will be installed:
libncurses-dev libreadline-dev
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 481 kB of archives.
After this operation, 3,166 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates/main amd64 libncurses-dev amd64 6.2-0ubuntu2.1 [340 kB]
Get:2 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal/main amd64 libreadline-dev amd64 8.0-4 [141 kB]
Fetched 481 kB in 1s (446 kB/s)
Selecting previously unselected package libncurses-dev:amd64.
(Reading database ... 186036 files and directories currently installed.)
Preparing to unpack .../libncurses-dev_6.2-0ubuntu2.1_amd64.deb ...
Unpacking libncurses-dev:amd64 (6.2-0ubuntu2.1) ...
Selecting previously unselected package libreadline-dev:amd64.
Preparing to unpack .../libreadline-dev_8.0-4_amd64.deb ...
Unpacking libreadline-dev:amd64 (8.0-4) ...
Setting up libncurses-dev:amd64 (6.2-0ubuntu2.1) ...
Setting up libreadline-dev:amd64 (8.0-4) ...
Processing triggers for install-info (6.7.0.dfsg.2-5) ...
Processing triggers for man-db (2.9.1-1) ...
再次编译
# 下载Lua
mhzzj@mhzzj-virtual-machine:~/work/LuaCode$ wget -c http://www.lua.org/ftp/lua-5.3.0.tar.gz
mhzzj@mhzzj-virtual-machine:~/work/LuaCode$ tar -zxvf lua-5.3.0.tar.gz
mhzzj@mhzzj-virtual-machine:~/work/LuaCode$ cd lua-5.3.0/
# 后续步骤
mhzzj@mhzzj-virtual-machine:~/work/LuaCode/lua-5.3.0$ sudo make linux
mhzzj@mhzzj-virtual-machine:~/work/LuaCode/lua-5.3.0$ sudo make install
mhzzj@mhzzj-virtual-machine:~/work/LuaCode/lua-5.3.0$ lua -v
Lua 5.3.0 Copyright (C) 1994-2015 Lua.org, PUC-Rio