Search code examples
gccmakefilezlibhpc

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


Using CentOS 7. Installed zlib-devel, but still getting following error when trying to install softwares.

> 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

Also added -I/hpc/apps/zlib/1.2.11/include -I/usr/include to Makefile as following:

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


Solution

  • The makefile does not pass $(CFLAGS) to the compiler invocation, or the settings of the CFLAGS variable is not set in the makefile in the lib/utils directory, as can be seen from this command:

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

    You either need to add $(CFLAGS), or run the build system as intended (probably from the top-level build directory).