2

Hi I got a problem with my newly installed Fedora linux distribution. pkg-config is supposed to provide linker flags, something like pkg-config --cflags libboost-dev. But pkg-config cannot find most of the library packages. pkg-config --list-all shows that it can find only a few packages.

I searched online and learned that pkg-config finds packages by searching in the pre-defined paths for the *.pc files. However for most packages (both pre-installed and user-installed), there are no such .pc file. So the *.pc file is not generated everytime when a package installs.

1, How can I provide a .pc file for each of the packages that has already been installed? 2, How can I make sure that for each time a new package is installed, the .pc file is provided?

chrisb2244
  • 2,940
  • 22
  • 44
yu quan
  • 161
  • 1
  • 1
  • 14
  • I'm using dnf (previously yum in Fedora) to install most of the packages. – yu quan Oct 10 '15 at 05:06
  • Are you installing the `xyz-devel` packages, rather than just `xyz`? I think the development packages provide the .pc files since they also install headers - the normal packages typically do not – chrisb2244 Oct 10 '15 at 05:14
  • I tried boost, gsl, they both are used to develop c++ code, but don't have .pc files. – yu quan Oct 10 '15 at 05:17
  • I mean try (for example) `sudo dnf install boost-devel` or similar – chrisb2244 Oct 10 '15 at 05:19
  • @chrisb2244, not bad, gsl-dev can be found by pkg-config, however boost-dev cannot. May I also ask what is the typical difference between a dev version and the corresponding non-dev version? – yu quan Oct 10 '15 at 06:56
  • Fedora (and I think many distributions) use `-devel` to distinguish packages which contain the header files - that is, those which you would `#include` when building `c` and `c++` programs. Both the `devel` and standard packages include binaries (executable programs that do something) and libraries (which you can link binaries against - that is, they contain some set of instructions telling a program how to do something). Header files often end with `.h`, `.H`, `.hpp`, `.hxx` or similar, in contrast with source files which might end `.c`, `.C`, `.cpp`, `.cxx` etc – chrisb2244 Oct 10 '15 at 14:31
  • That means that if I have non-del versions then I cannot include the headers hence cannot use the libraries in my code? @chrisb2244 – yu quan Oct 11 '15 at 07:12
  • Right - see [this Fedora packaging guideline](https://fedoraproject.org/wiki/Packaging:Guidelines#Pkgconfig_Files_.28foo.pc.29) link for information about the concepts used at Fedora. The section immediately above also describes `-devel` packages – chrisb2244 Oct 11 '15 at 07:21

1 Answers1

2

The Fedora packaging guidelines give information about the way in which packages should be created, and the files they should contain.

The section about -devel packages is particularly relevant.

To highlight some parts

There are some types of files which almost always belong in a -devel package:

  • Header files (foo.h), usually found in /usr/include
  • Static library files when the package does not provide any matching shared library files. See Packaging:Guidelines#Packaging_Static_Libraries for more information about this scenario.
  • Unversioned shared system library files, when a matching versioned shared system library file is also present.

In the next section, regarding Pkgconfig Files, the page informs the reader that

The placement of pkgconfig(.pc) files depends on their usecase. Since they are almost always used for development purposes, they should be placed in a -devel package.

A reasonable exception is when the main package itself is a development tool not installed in a user runtime, e.g. gcc or gdb.

As a result, in order to get either header files to #include, or .pc files to tell you compiler flags, you will need the xyz-devel package, where xyz is the name of the standard package.

A useful website to find the appropriate names of packages to install, if you can't/don't want to guess them, is the Fedora Packages search page.

Community
  • 1
  • 1
chrisb2244
  • 2,940
  • 22
  • 44