简体   繁体   English

pkg-config在gcc中有什么意义?

[英]what is the significance of pkg-config in gcc?

While building a dbus-example, I found that we need to add a pkg-config in gcc. 在构建dbus示例时,我发现我们需要在gcc中添加pkg-config。 For example: 例如:

gcc `pkg-config --cflags --libs dbus-1` <file_name> -o <file_name.out>

What is the significance of pkg-config --cflags --libs dbus-1 ? pkg-config --cflags --libs dbus-1什么意义? what is pkg-config here? 这是什么pkg-config? what is cflags extra here? 什么是额外的cflags? what is --libs here? 什么是--libs在这里?

gcc `pkg-config --cflags --libs dbus-1` <file_name> -o <file_name.out>

will run the pkg-config command, and pass its output as parameters to gcc. 将运行pkg-config命令,并将其输出作为参数传递给gcc。

The purpose of pkg-config is to make linking against libraries much easier, as different operating systems and distributions require different compilation flags (aka CFLAGS ), library inclusion paths and libraries to link to. pkg-config的目的是使库的链接更容易,因为不同的操作系统和发行版需要不同的编译标志(也称为CFLAGS ),库包含路径和链接到的库。 pkg-config uses configuration files (defined by the libraries) to generate the above information for compilers, and allows us to not worry about what operating system or distribution the compilation takes place on. pkg-config使用配置文件(由库定义)为编译器生成上述信息,并且使我们不必担心编译发生在哪个操作系统或分发上。

--cflags means the pkg-config should give the compilation flags for the listed packages. --cflags表示pkg-config应该为列出的包提供编译标志。 --libs means the pkg-config should give the linking information for the listed packages. --libs表示pkg-config应该为列出的包提供链接信息。

and dbus-1 is the name of the package. dbus-1是包的名称。

gcc `pkg-config --cflags --libs dbus-1` <file_name> -o <file_name.out>

comprises these parts: 包括以下部分:

  1. executing the pkg-config --cflags --libs dbus-1 note `` run the command in between. 执行pkg-config --cflags --libs dbus-1在其间运行命令。
  2. run gcc with the flags 1. returns and an input file <file_name> output object file . 使用标志运行gcc 1.返回和输入文件<file_name>输出对象文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM