pkg-config在gcc中的意义是什么? [英] what is the significance of pkg-config in gcc?
问题描述
在构建dbus示例时,我发现我们需要在gcc中添加pkg-config。例如:
gcc`pkg-config --cflags --libs dbus-1`< file_name> -o< file_name.out>
pkg-config --cflags --libs dbus的意义-1
?什么是pkg-config在这里?什么是cflags额外在这里?什么是 - libs
在这里?
gcc`pkg-config --cflags --libs dbus-1`< file_name> -o< file_name.out>
将运行 pkg-config
命令,并将其输出作为参数传递给gcc。
pkg-config 的目的是为了链接库因为不同的操作系统和发行版需要不同的编译标志(又名 CFLAGS
),库包含路径和库链接。 pkg-config
使用配置文件(由库定义)为编译器生成上述信息,并且使我们无需担心编译发生在哪个操作系统或分发版上。
- cflags
表示 pkg-config
应该为列出的软件包提供编译标志。
- libs
表示 pkg-config
应该给出列出的软件包的链接信息。
和 dbus-1
是包的名称。
While building a dbus-example, I found that we need to add a pkg-config in gcc. 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
? what is pkg-config here? what is cflags extra here? what is --libs
here?
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.
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
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.
--cflags
means the pkg-config
should give the compilation flags for the listed packages.
--libs
means the pkg-config
should give the linking information for the listed packages.
and dbus-1
is the name of the package.
这篇关于pkg-config在gcc中的意义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!