文档
pkg-config指南 https://people.freedesktop.org/~dbn/pkg-config-guide.html
介绍
pkg-config是在编译应用程序和库时使用的辅助工具。它可以帮助您在命令行上插入正确的编译器选项,以便应用程序可以使用。主要用途是为编译程序并将其链接到库提供必要的详细信息。
gcc -o test test.c `pkg-config --libs --cflags glib-2.0`
pkg-config会到/usr/lib/pkconfig/寻找.pc文件。其它路径下的.pc文件,则需要通过PKG_CONFIG_PATH环境变量来指定。
配置环境变量
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
选项
| —libs | 连接器 -L xxx, -l xxx | |
|---|---|---|
| —libs-only-L | -L xxx | |
| —libs-only-l | -l xxx | |
| —cflags | 预处理器和编译器标志 -I等 | |
| —cflags-only-I | -I | |
$pkg-config --cflags libhs-I/usr/local/include/hs
$pkg-config --libs libhs-L/usr/local/lib -lhs
$pkg-config --cflags --libs libhs-I/usr/local/include/hs -L/usr/local/lib -lhs
程序版本--modversion
$pkg-config --modversion libhs4.4.1
列出所有程序--list-all
pkg-config --list-all
dpdk已安装才打印1
$ pkg-config --exists libdpdk && echo 11
