config search path: (search for .pc)
pkg-config --variable pc_path pkg-config
/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
PKG_CONFIG_PATH
範例
prefix=/usr
exec_prefix=${prefix}
libdir=/usr/lib/x86_64-linux-gnu
includedir=${prefix}/include
Name: x264
Description: H.264 (MPEG4 AVC) encoder library
Version: 0.148.2643 5c65704
Libs: -L/usr/lib/x86_64-linux-gnu -lx264
Libs.private: -lpthread -lm -ldl
Cflags: -I${prefix}/include
pkg-config exits with a nonzero code if it can’t find metadata for one or more of the packages on the command line
Libs: link flags
Libs.private: Private libraries are libraries which are not exposed through your library, but are needed in the case of static linking
Cflags: preprocessor flags, compiler flags, 不需要加上required package flags (pkg-config會處理)
常見用法: (配合autotools or Makefile使用)
–cflags, –libs
CXXFLAGS += $(shell pkg-config --cflags libavformat libavcodec libavutil)
LDFLAGS += $(shell pkg-config --libs libavformat libavcodec libavutil)