栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

pkg-config 查找库和用于编译

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

pkg-config 查找库和用于编译

今天在看LTTng 文档的时候看到这个指令。

gcc -o notif-app notif-app.c $(pkg-config --cflags --libs lttng-ctl)

查了一下 pkg-config是一个linux下的命令,用于获得某一个库/模块的所有编译相关的信息。

pkg-config --cflags --libs lttng-ctl执行结果:

-I/usr/local/include -L/usr/local/lib -llttng-ctl

那以后编译程序连接很多安装的库和接口的时候就可以省力很多了。

DESCRIPTION

   The pkg-config program is used to retrieve information about installed  libraries  in  the
   system.   It is typically used to compile and link against one or more libraries.  Here is
   a typical usage scenario in a Makefile:

   program: program.c
        cc program.c $(pkg-config --cflags --libs gnomeui)

   pkg-config retrieves information about packages from special metadata files.  These  files
   are  named  after the package, and has a .pc extension.  On most systems, pkg-config looks
   in     /usr/lib/pkgconfig,     /usr/share/pkgconfig,     /usr/local/lib/pkgconfig      and
   /usr/local/share/pkgconfig  for  these  files.   It  will  additionally look in the colon-
   separated  (on  Windows,  semicolon-separated)  list  of  directories  specified  by   the
   PKG_CONFIG_PATH environment variable.

   The package name specified on the pkg-config command line is defined to be the name of the
   metadata file, minus the .pc  extension.  If  a  library  can  install  multiple  versions
   simultaneously,  it  must  give each version its own name (for example, GTK 1.2 might have
   the package name "gtk+" while GTK 2.0 has "gtk+-2.0").

   In addition to specifying a package name on the command line, the full path to a given .pc
   file may be given instead. This allows a user to directly query a particular .pc file.
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/940738.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号