编译GCC报错 zlib.h 缺失解决方案

编译GCC报错 zlib.h 缺失解决方案

错误信息

../../gcc/lto-compress.c:34:18: fatal error: zlib.h: No such file or directory
compilation terminated.
Makefile:1116: recipe for target 'lto-compress.o' failed

解决方案

安装缺失的依赖包即可:

# Ubuntu/Debian
sudo apt install zlib1g-dev

或者安装完整的开发工具链

sudo apt install build-essential zlib1g-dev libmpc-dev libmpfr-dev libgmp-dev

然后重新编译:

# 清理之前的编译
make clean

重新编译

make -j$(nproc)

错误原因

编译GCC需要 zlib.h 头文件,但系统中没有安装 zlib-dev 包。

安装后应该就能正常编译了!

发表回复

后才能评论