I have zlib and pkg-config installed and pkg-config could find zlib:
$ pkg-config --list-all | grep zlib
zlib zlib - zlib compression library
pkg-config --libs
is working:
$ pkg-config --libs zlib
-lz
but pkg-config --cflags
couldn't find header files of zlib:
$ pkg-config --cflags zlib
prints nothing
$ cat /usr/lib64/pkgconfig/zlib.pc
prefix=/usr
exec_prefix=${prefix}
libdir=/usr/lib64
sharedlibdir=${libdir}
includedir=/usr/include
Name: zlib
Description: zlib compression library
Version: 1.2.7
Requires:
Libs: -L${libdir} -L${sharedlibdir} -lz
Cflags: -I${includedir}
Why pkg-config couldn't find zlib? (I'm using CentOS 7 if it matters)
pkg-config
did find the cflags for zlib.
However, /usr/include
is one of the default include paths searched by the compiler. Therefore pkg-config
filters it from the output, so that the compiler won't search it twice.
For the same reason --libs
produced only -lz
, not including the library path -L/usr/lib64
which is also a default.