Ubuntu解决Lua编译报错lua.c:80:10: fatal error: readline/readline.h: No such file or directory

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值