This page contains best practices for packages that make use of or depend on C or C++ in Fedora, from package development all the way to package maintenance.
C and C++
The C and C++ languages and runtimes are one of the most common development frameworks for packages in fedora. As such there is a wide variety of quality, style, and convention in all of those packages. The follow document provides best practice for certain aspects of C and C++.
BuildRequires and Requires
If your application is a C or C++ application you must list a
clang. Those packages will include everything that is required to build a standards conforming C or C++ application.
If your library includes standard C or C++ headers, you must list
clang to install the needed standards conforming headers.
If at runtime you use
cpp to process C or C++ language headers then you have no choice but to use
clang to install the required headers for a standard conforming C or C++ application. In the future this might change if a set of standard C or C++ language headers are provided by a special-purpose provides e.g.
You need not include a
glibc-headers, or any other core C or C++ implementation package unless you have a specific and special need e.g. static compilation requires the
.*-static library packages e.g.
BuildRequires: glibc-static. The default use case of a dynamically compiled C or C++ application is taken care of by the
Please refer to Packaging:Guidelines Compiler for the list of supported compilers for C and C++ compilers.
Q: Do I need a
Requires: glibc to ensure I have the C runtime installed for my application?
A: No. RPM will automatically determine what ELF libraries you need based on the binaries in your package. This is sufficient to cause glibc to be installed.
Q: Do I need to include a
A: If you are using an API from
libgcc directly, then yes, you must have a
Requires: libgcc. In general though
libgcc, so it is always installed.
Libraries should have unique shared object names (SONAMEs) that do not conflict with other library SONAMEs used in the distribution. For example there should only be one
libfoo.so in the distribution. The only exception is when there are multiple implementations of the same library
libfoo.so provided by different authors and each conflicts with the other. In this case both
libfoo.so must provide exactly the same interface, but with a different implementation. Having two
libfoo.so each with a different API is bad practice and makes it harder to package and distribute those packages.
Libraries should versions all of their symbols using a version script. Versioning allows the library to avoid changing the SONAME when the API changes and instead compatibility functions can be written to provide backwards compatibility for older applications.
No additional suggestions are provided for applications at this time.