文档
    pkg-config指南 https://people.freedesktop.org/~dbn/pkg-config-guide.html
    介绍
    pkg-config是在编译应用程序和库时使用的辅助工具。它可以帮助您在命令行上插入正确的编译器选项,以便应用程序可以使用。主要用途是为编译程序并将其链接到库提供必要的详细信息。

    1. gcc -o test test.c `pkg-config --libs --cflags glib-2.0`

    pkg-config会到/usr/lib/pkconfig/寻找.pc文件。其它路径下的.pc文件,则需要通过PKG_CONFIG_PATH环境变量来指定。

    1. 配置环境变量

      1. export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
    2. 选项

    —libs 连接器 -L xxx, -l xxx
    —libs-only-L -L xxx
    —libs-only-l -l xxx
    —cflags 预处理器和编译器标志 -I等
    —cflags-only-I -I
    1. $pkg-config --cflags libhs
    2. -I/usr/local/include/hs
    1. $pkg-config --libs libhs
    2. -L/usr/local/lib -lhs
    1. $pkg-config --cflags --libs libhs
    2. -I/usr/local/include/hs -L/usr/local/lib -lhs

    程序版本--modversion

    1. $pkg-config --modversion libhs
    2. 4.4.1

    列出所有程序--list-all

    1. pkg-config --list-all

    dpdk已安装才打印1

    1. $ pkg-config --exists libdpdk && echo 1
    2. 1