Compiling GMime Applications

Compiling GMime Applications — How to compile your GMime application

Compiling GMime Applications on UNIX

To compile a GMime application, you need to tell the compiler where to find the GMime header files and libraries. This is done with the pkg-config utility.

The following interactive shell session demonstrates how pkg-config is used:

$ pkg-config --cflags gmime-4.0
 -I/usr/include/gmime-4.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
$ pkg-config --libs gmime-4.0
 -L/opt/gnome2/lib -lgmime-4.0 -lnsl -lgobject-2.0 -lglib-2.0

The simplest way to compile a program is to use the "backticks" feature of the shell. If you enclose a command in backticks (not single quotes), then its output will be substituted into the command line before execution. So to compile a GTK+ Hello, World, you would type the following:

$ cc `pkg-config --cflags --libs gmime-4.0` hello.c -o hello

For native cryptography, include gmime/gmime-gpgme.h and use pkg-config --cflags --libs gmime-gpgme-4.0. This integration package is installed only when cryptography is enabled. Contexts, keys, and results use native GPGME types; they are not GObjects and these methods are not exposed through GObject introspection.