how to compile the freetype example
last updated: Oct 20, 2023
here is the freetype tutorial, which includes a link (hidden at the end(!?)) to an example C program with limited instructions for how to use the thing.
This makefile builds it, which it took me a bit to figure out:
INCLUDE_FLAGS=$(shell pkg-config --cflags --libs freetype2)
example: example1.c
$(CC) $(INCLUDE_FLAGS) $< -o $@
- the tutorial gives
pkg-config --cflags freetype2, but it took me some googling to figure out--cflags --libswas what I wanted - this outputs three types of flags:-Itells the c compiler where to find the header files-Ltells the c compiler where to find the dynamic library for freetype-ltells the c compiler what library to choose, maybe?- The full output on this system is:
-I/opt/homebrew/opt/freetype/include/freetype2 -L/opt/homebrew/opt/freetype/lib -lfreetype - I had tried combinations of
-I, and one of-Land-lbefore finding that you needed all three, for reasons that are not clear to me
$<means "all prerequisites of this task" which in this case is justexample1.c$@means "the output file of this task" which in this case isexample- I was able to run the example program and it prints something giant to my console that I don't understand