简体   繁体   English

pkg-config 找不到 header 的 zlib

[英]pkg-config couldn't find header of zlib

I have zlib and pkg-config installed and pkg-config could find zlib:我安装了 zlib 和 pkg-config,pkg-config 可以找到 zlib:

$ pkg-config --list-all | grep zlib
zlib                      zlib - zlib compression library

pkg-config --libs is working: pkg-config --libs正在工作:

$ pkg-config --libs zlib
-lz  

but pkg-config --cflags couldn't find header files of zlib:但是pkg-config --cflags找不到 header 个 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?为什么 pkg-config 找不到 zlib? (I'm using CentOS 7 if it matters) (如果重要的话,我正在使用 CentOS 7)

pkg-config did find the cflags for zlib. pkg-config确实找到了 zlib 的 cflags。

However, /usr/include is one of the default include paths searched by the compiler.但是, /usr/include是编译器搜索的默认包含路径之一。 Therefore pkg-config filters it from the output, so that the compiler won't search it twice.因此pkg-config从 output 中过滤掉它,这样编译器就不会搜索它两次。

For the same reason --libs produced only -lz , not including the library path -L/usr/lib64 which is also a default.出于同样的原因--libs只产生-lz ,不包括库路径-L/usr/lib64这也是默认的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM