-
Notifications
You must be signed in to change notification settings - Fork 288
/
README_pkgconfig.txt
61 lines (38 loc) · 2.12 KB
/
README_pkgconfig.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Using pkg-config with Allegro
=============================
On Unix-like operating systems, we use the pkg-config tool to simplify the
process of linking with Allegro.
To print the list of Allegro libraries installed, you can run:
pkg-config --list-all | grep allegro
You may need to set the PKG_CONFIG_PATH environment variable appropriately if
/usr/local/lib/pkgconfig is not hardcoded for your version of pkg-config or
if you installed to a non-standard location. For example:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
To print the command line options required to link with the core Allegro
library and the image addon, you would run:
pkg-config --libs allegro-5 allegro_image-5
which outputs something like:
-L/usr/lib -lallegro_image -lallegro
If you use static libraries, you need to add the --static option:
pkg-config --libs --static allegro-static-5 allegro_image-static-5
which will include additional libraries needed for static linking.
This can be combined with shell command substitution:
gcc mygame.c -o mygame $(pkg-config --libs allegro-5 allegro_image-5)
If Allegro is installed to a non-standard location, the compiler will need
command line options to find the header files. The pkg-config `--cflags`
option provides that information. You can combine it with `--libs` as well:
pkg-config --cflags --libs allegro-5 allegro_image-5
Most build systems will allow you to call pkg-config in a similar way to the
shell. For example, a very basic Makefile might look like this:
ALLEGRO_LIBRARIES := allegro-5 allegro_image-5
ALLEGRO_FLAGS := $(shell pkg-config --cflags --libs $(ALLEGRO_LIBRARIES))
mygame: mygame.c
$(CC) -o $@ $^ $(ALLEGRO_FLAGS)
Historical note
---------------
Prior to Allegro 5.0.9 the .pc files were named allegro-5.0.pc and so on.
To ease transitioning to future versions of Allegro the minor version
number was dropped, leaving allegro-5.pc and so on. The old names are
deprecated but will remain available in 5.0.x releases.
Configuration scripts should look for Allegro using the new pkg-config
names first, then the old names, for greater compatibility.