最終更新:2023-04-17 (月) 17:41:52 (364d)  

pkg-config
Top / pkg-config

http://pkg-config.freedesktop.org/wiki/

pkg-config is a helper tool used when compiling applications and libraries. It helps you insert the correct compiler options on the command line so an application can use

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

for instance, rather than hard-coding values on where to find glib? (or other libraries). It is language-agnostic, so it can be used for defining the location of documentation tools, for instance.

ソフトウエアをコンパイルする際に必要なライブラリがあるか、 バージョンは必要条件を満たしているか、既にインストールされている他のものと 衝突しないか、などを調査してコンパイラに渡す引数を生成してくれる

通常、configure から呼び出されて使用される。

概要

  • 環境変数PKG_CONFIG_PATHのパスに存在する *.pc ファイルに記録された情報を元に、ビルドの際に必要な文字列を返す。
    pkg-config --libs libv4l1
  • 引数のライブラリ名はパッケージによるので一覧(--list-all)で確認

  • gcc -o cvtest cvtest.c `pkg-config --cflags --libs opencv`
    gcc -o cvtest cvtest.c -I/usr/include/opencv -lhighgui -lcvaux -lcv -lml -lcxcore

help

  • Usage:
    
      pkg-config [OPTION?]
    
    
    
    Help Options:
    
      -h, --help                              Show help options
    
    
    
    Application Options:
    
      --version                               output version of pkg-config
    
      --modversion                            output version for package
    
      --atleast-pkgconfig-version=VERSION     require given version of pkg-config
    
      --libs                                  output all linker flags
    
      --static                                output linker flags for static linking
    
      --short-errors                          print short errors
    
      --libs-only-l                           output -l flags
    
      --libs-only-other                       output other libs (e.g. -pthread)
    
      --libs-only-L                           output -L flags
    
      --cflags                                output all pre-processor and compiler flags
    
      --cflags-only-I                         output -I flags
    
      --cflags-only-other                     output cflags not covered by the cflags-only-I option
    
      --variable=NAME                         get the value of variable named NAME
    
      --define-variable=NAME=VALUE            set variable NAME to VALUE
    
      --exists                                return 0 if the module(s) exist
    
      --print-variables                       output list of variables defined by the module
    
      --uninstalled                           return 0 if the uninstalled version of one or more module(s) or their dependencies will be used
    
      --atleast-version=VERSION               return 0 if the module is at least version VERSION
    
      --exact-version=VERSION                 return 0 if the module is at exactly version VERSION
    
      --max-version=VERSION                   return 0 if the module is at no newer than version VERSION
    
      --list-all                              list all known packages
    
      --debug                                 show verbose debug information
    
      --print-errors                          show verbose information about missing or conflicting packages (default unless --exists or --atleast/exact/max-version given on the command line)
    
      --silence-errors                        be silent about errors (default when --exists or --atleast/exact/max-version given on the command line)
    
      --errors-to-stdout                      print errors from --print-errors to stdout not stderr
    
      --print-provides                        print which packages the package provides
    
      --print-requires                        print which packages the package requires
    
      --print-requires-private                print which packages the package requires for static linking
    
      --validate                              validate a package's .pc file
    
      --define-prefix                         try to override the value of prefix for each .pc file found with a guesstimated value based on the location of the .pc file
    
      --dont-define-prefix                    don't try to override the value of prefix for each .pc file found with a guesstimated value based on the location of the .pc file
    
      --prefix-variable=PREFIX                set the name of the variable that pkg-config automatically sets

検索パス (.pc)

CentOS 5

Ubuntu

一覧

追加

ガイド

関連

参考