Using pkg-config as compiler and linker flags
From AcrodusWiki
Came across pkg-config files for the first time when using gtk4. The below extract is the makefile for that hello world test.
CFLAGS = -Wall -g `pkg-config --cflags gtk4` LDFLAGS = `pkg-config --libs gtk4` all: gtk_test.c gcc -o gtk_test gtk_test.c $(CFLAGS) $(LDFLAGS) clean: rm -f *~ rm -f *.o rm -f gtk_test
Main thing here is the addition of the compiler and linker flags at the top. These use the shell environment variable PKG_CONFIG_PATH to look for pkg-config files "*.pc" that specify meta data on how to compile and link in the library. I had to find the location of the gtk4.pc file and add it to the PKG_CONFIG_PATH variable with the below commands.
sudo find -type f -name "gtk.pc"
export PKG_CONFIG_PATH=/usr/lib