fatal error: zlib.h: No such file or directory when zlib is installed

fatal error: zlib.h: No such file or directory when zlib is installed

使用 CentOS 7。 已安装 zlib-devel,但在尝试安装软件时仍然出现以下错误。

> make
make -C lib/utils libutils.a
make[1]: Entering directory '/common/apps/biscuit/lib/utils'
gcc -c -Wall -O2 wzvcf.c -o wzvcf.o
In file included from wzvcf.h:29:0,
             from wzvcf.c:1:
wzio.h:4:10: fatal error: zlib.h: No such file or directory
 #include <zlib.h>
      ^~~~~~~~
compilation terminated.
make[1]: *** [Makefile:17: wzvcf.o] Error 1
make[1]: Leaving directory '/common/apps/biscuit/lib/utils'
make: *** [Makefile:60: lib/utils/libutils.a] Error 2

还添加了 -I/hpc/apps/zlib/1.2.11/include -I/usr/include 到 Makefile 如下:

CC = gcc
CFLAGS = -W -Wall -finline-functions -fPIC -std=gnu99 -Wno-unused-result -O3 -I/hpc/apps/zlib/1.2.11/include -I/usr/include
CLIB = -lncurses -lpthread -lz -lm
CF_OPTIMIZE = 1

makefile没有将$(CFLAGS)传递给编译器调用,或者CFLAGS变量的设置在lib/utils目录下的makefile中没有设置,可以看出从这个命令:

gcc -c -Wall -O2 wzvcf.c -o wzvcf.o

您需要添加 $(CFLAGS) 或 运行 构建系统(可能来自顶级构建目录)。