在linux下使用gcc编译项目时,一般都需要使用非标准的库和头文件,而这些文件在不同人的系统里可能装在不同路径,编译时需要使用-I指定头文件目录,使用-L指定库文件目录.为了让编译时的命令统一,有了pkg-config.它是一个提取库信息的工具.通过库提供的.pc文件可以从中提取信息.支持pkg-config的库对应的.pc文件一般在lib/pkgconfig目录下.
如gtk+-2.0.pc的内容为:
prefix=/devel/target/0684580203da616c0bb222943906b663
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
target=win32
gtk_binary_version=2.10.0
gtk_host=i686-pc-mingw32
Name: GTK+
Description: GTK+ Graphical UI Library (${target} target)
Version: 2.24.8
Requires: gdk-${target}-2.0 atk cairo gdk-pixbuf-2.0 gio-2.0
Libs: -L${libdir} -lgtk-${target}-2.0
Cflags: -I${includedir}/gtk-2.0 -mms-bitfields
如:pkg-config --cflags --libs gtk+-2.0就会输出gtk及其依赖的库的信息.然后可以利用这些信息去进行编译.
但pkg-config是怎么获得这些信息的呢?它使用PKG_CONFIG_PATH去指定搜索的目录.所以当我们安装了新的库且不在gcc默认搜索的目录时,可以使用-I和-L选项或者使用pkg-config.
例如:gcc -o test test.c 'pkg-config --libs --cflags gtk+-2.0'
分享到:
相关推荐
用于C++ Rust windows环境开发的基础工具,pkg-config-lite-0.28-1_bin-win32
pkg-config 是通过库提供的一个 .pc 文件获得库的各种必要信息的,包括版本信息、编译和连接需要的参数等。这些信息可以通过 pkg-config 提供的参数单独提取出来直接供编译器和连接器使用。
pkg-config本身是一个linux下的命令,其功能是用于获得某一个库/模块的所有编译相关的信息。 # 在windows上面配置pkg-config 将下载的pkg-config_0.23-2_win64解压,解压的bin与MinGW-w64里的的bin目录合并。
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-...
pkg-config for windows x64
pkg-config-0.28.tar.gz
pkg-config for windows x86
分享pkg-config-0.29.1.tar.gz源码资源,解决国外站点下载很慢
pkg-config_0.23-3_win32.zip
pkg-config用来检索系统中安装库文件的信息。典型的是用作库的编译和连接。如在Makefile中
pkg-config is a script to make putting together all the build flags when compiling/linking a lot easier. Report bugs at http://bugzilla.freedesktop.org/
pkg-config-rs 一个简单的库,打算与Cargo软件包一起用作构建依赖项,以便使用系统pkg-config工具(如果有)来确定库的位置。 您可以直接使用此板条箱来探查特定的库,也可以使用在中声明所有pkg-config依赖Cargo....
本人在网上搜集的pkg-config压缩包,可以正常使用,适合使用mingw和msys交叉编译时提示缺少pkg-config的情况。
离线安装包,亲测可用
官方离线安装包,亲测可用
pkgconfig是一个与pkg-config命令行工具连接的Python模块,并支持Python 2.6+和3.3+。 它可以用来 查找所有pkg-config软件包 >>> packages = pkgconfig.list_all() 检查包是否存在 >>> pkgconfig.exists('glib-2.0...
pkg-config-dev_0.23-3_win32 编程出错时可能确实的包错误如下 configure.ac:1: error: possibly undefined macro: dnl If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf ...
pkg-config.exe
官方离线安装包,亲测可用