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 --libshere?
will run the
pkg-configcommand, and pass its output as parameters to gcc.The purpose of
pkg-configis to make linking against libraries much easier, as different operating systems and distributions require different compilation flags (akaCFLAGS), library inclusion paths and libraries to link to.pkg-configuses 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.--cflagsmeans thepkg-configshould give the compilation flags for the listed packages.--libsmeans thepkg-configshould give the linking information for the listed packages.and
dbus-1is the name of the package.