Heesung Yang

[명령어] pkg-config

용도

  • 외부 라이브러리를 사용하여 컴파일 시 링크 옵션을 직접 타이핑하는 대신 라이브러리 이름으로 컴파일 옵션을 출력할 수 있는 툴

  • pkg-config는 *.pc 파일을 읽어서 출력하는 명령어

  • 보통 /usr/lib64/pkgconfig 폴더 하위에 *.pc 파일들 존재

  • *.pc 파일 샘플 (/usr/lib64/pkgconfig/openssl.pc)

    prefix=/usr
    exec_prefix=${prefix}
    libdir=${exec_prefix}/lib64
    includedir=${prefix}/include
    
    Name: OpenSSL
    Description: Secure Sockets Layer and cryptography libraries and tools
    Version: 1.1.1k
    Requires: libssl libcrypto
    

사용 예시

# openssl 라이브러리 링크 옵션
~$ pkg-config --libs openssl
-lssl -lcrypto

# openssl 라이브러리를 static 으로 링크할 시 openssl 이 사용하는 외부 라이브러리도 함께 출력
~$ pkg-config --libs --static openssl
-lssl -lgssapi_krb5 -lkrb5 -lcom_err -lk5crypto -lcrypto -ldl -lz

# 사용 가능한 라이브러리 목록
~$ pkg-config --list-all
fontutil                       FontUtil - Font utilities dirs
grilo-plugins-0.3              Grilo Framework Plugins - Plugins for the Grilo Framework
libcrypt                       libxcrypt - Extended crypt library for DES, MD5, Blowfish and others
libxcrypt                      libxcrypt - Extended crypt library for DES, MD5, Blowfish and others
zlib                           zlib - zlib compression library
libelf                         libelf - elfutils libelf library to read and write ELF files
libzstd                        zstd - fast lossless compression algorithm library
liblzma                        liblzma - General purpose data compression library
libdw                          libdw - elfutils library for DWARF data and ELF file or process inspection
valgrind                       Valgrind - A dynamic binary instrumentation framework
com_err                        com_err - Common error description library
libpcre2-16                    libpcre2-16 - PCRE2 - Perl compatible regular expressions C library (2nd API) with 16 bit character support
libpcre2-32                    libpcre2-32 - PCRE2 - Perl compatible regular expressions C library (2nd API) with 32 bit character support
libpcre2-8                     libpcre2-8 - PCRE2 - Perl compatible regular expressions C library (2nd API) with 8 bit character support
libpcre2-posix                 libpcre2-posix - Posix compatible interface to libpcre2-8
libsepol                       libsepol - SELinux policy library
libselinux                     libselinux - SELinux utility library
libverto                       libverto - Event loop abstraction interface
gssrpc                         gssrpc - GSSAPI RPC implementation
kadm-client                    kadm-client - Kerberos administration client library
kadm-server                    kadm-server - Kerberos administration server library
kdb                            kdb - Kerberos database access libraries
krb5-gssapi                    krb5-gssapi - Kerberos implementation of the GSSAPI
krb5                           krb5 - An implementation of Kerberos network authentication
mit-krb5-gssapi                mit-krb5-gssapi - Kerberos implementation of the GSSAPI
mit-krb5                       mit-krb5 - An implementation of Kerberos network authentication
libcrypto                      OpenSSL-libcrypto - OpenSSL cryptography library
libssl                         OpenSSL-libssl - Secure Sockets Layer and cryptography libraries
openssl                        OpenSSL - Secure Sockets Layer and cryptography libraries and tools
libxml-2.0                     libXML - libXML library version2.
libpng                         libpng - Loads and saves PNG files
libpng16                       libpng - Loads and saves PNG files
libquvi-scripts-0.9            libquvi-scripts - Scripts for libquvi
mallard-rng                    mallard-rng - Mallard RELAX NG Schemas
dracut                         dracut - dracut
shared-mime-info               shared-mime-info - Freedesktop common MIME database
systemd                        systemd - systemd System and Service Manager
udev                           udev - udev
gnome-video-effects            gnome-video-effects - A collection of GStreamer effects to be used in different GNOME Modules
gnome-keybindings              gnome-keybindings - Keybindings configuration for GNOME applications
bash-completion                bash-completion - programmable completion for the bash shell

Previous post

[Python] pytest 팁