File: gpgme.info, Node: Building the Source, Next: Largefile Support (LFS), Prev: Header, Up: Preparation 2.2 Building the Source ======================= If you want to compile a source file including the ‘gpgme.h’ header file, you must make sure that the compiler can find it in the directory hierarchy. This is accomplished by adding the path to the directory in which the header file is located to the compilers include file search path (via the ‘-I’ option). However, the path to the include file is determined at the time the source is configured. To solve this problem, gpgme ships with ‘gpgme.pc’ file, that knows about the path to the include file and other configuration options. The command, ‘pkg-config’, can be used to handle information with ‘gpgme.pc’ file. In an environment which doesn’t have ‘pkg-config’ (like the one in early stage of OS bootstrap), for Automake, you can use ‘gpgme.m4’ which invokes ‘gpgrt-config’ with ‘gpgme.pc’. (In the past, gpgme used to ship with a small helper program ‘gpgme-config’. This functionality of ‘gpgme-config’ is replaced by ‘pkg-config’ with ‘gpgme.pc’ file.) The options that need to be added to the compiler invocation at compile time are output by the ‘--cflags’ option to ‘pkg-config gpgme’. The following example shows how it can be used at the command line: gcc -c foo.c `pkg-config --cflags gpgme` Adding the output of ‘pkg-config --cflags gpgme’ to the compiler command line will ensure that the compiler can find the GPGME header file. A similar problem occurs when linking the program with the library. Again, the compiler has to find the library files. For this to work, the path to the library files has to be added to the library search path (via the ‘-L’ option). For this, the option ‘--libs’ to ‘pkg-config gpgme’ can be used. For convenience, this option also outputs all other options that are required to link the program with GPGME (in particular, the ‘-lgpgme’ option). The example shows how to link ‘foo.o’ with the GPGME library to a program ‘foo’. gcc -o foo foo.o `pkg-config --libs gpgme` Of course you can also combine both examples to a single command by specifying both options to ‘pkg-config gpgme’: gcc -o foo foo.c `pkg-config --cflags --libs gpgme`