Create pkg-config file
pkg-config is a standard tool to provide compiler and linker information to users of a library. The advantages of pkg-config are
- simplicity (short plain text configuration files),
- availability, and
- usability.
For example, to use OpenBLAS on Ubuntu 20.04 the following flags are necessary:
$ pkg-config --cflags --libs openblas
-I/usr/include/x86_64-linux-gnu/openblas-pthread/ -L/usr/lib/x86_64-linux-gnu/openblas-pthread/ -lopenblas
The can be easily used directly on the command line or in a Makefile, they also allow comoilation and linking in separate steps:
$ gcc $(pkg-config --cflags openblas) code.c -c -o code.o
$ gcc code.o -o executable $(pkg-config --libs openblas)
The advantage of pkg-config over CMake configurations is that only CMake can use these target files whereas CMake has built-in functionality to use pkg-config.