我按照 GTK 上的教程使用此命令生成构建标志:
$ pkg-config --cflags --libs gtk+-3.0
Run Code Online (Sandbox Code Playgroud)
这将输出相干标志。从研究中,我发现在、、等价物以及变量指示的文件夹中pkg-config搜索.pc文件。/usr/lib/pkginfousr/share/pkgconfig/localPKG_CONFIG_PATH
没有一个文件夹包含 GTK 文件,并且没有设置环境变量。从哪里pkg-config获得旗帜?
它/usr/lib/x86_64-linux-gnu/pkgconfig/gtk+-3.0.pc正在(假设您在amd64)中找到它们。在 Debian 上,pkg-config还要搜索目标的多架构目录,即 /usr/lib/$(dpkg-architecture -q DEB_TARGET_MULTIARCH)/pkgconfig.
手册页中提供了一些很好的技巧,可用于从pkg-config自身获取此信息。
PKG-CONFIG DERIVED VARIABLES
pc_path
The default search path used by pkg-config when searching for
.pc files. This can be used in a query for the pkg-config module
itself itself:
$ pkg-config --variable pc_path pkg-config
pcfiledir
The installed location of the .pc file. This can be used to
query the location of the .pc file for a particular module, but
it can also be used to make .pc files relocatable.
Run Code Online (Sandbox Code Playgroud)
例如,查看系统/架构的实际搜索路径:
$ pkg-config --variable pc_path pkg-config | tr ':' '\n'
/usr/local/lib/x86_64-linux-gnu/pkgconfig
/usr/local/lib/pkgconfig
/usr/local/share/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/pkgconfig
/usr/share/pkgconfig
Run Code Online (Sandbox Code Playgroud)
并获取.pc找到特定包文件的位置
$ pkg-config --variable pcfiledir gtk+-3.0
/usr/lib/x86_64-linux-gnu/pkgconfig
Run Code Online (Sandbox Code Playgroud)