Compiling libtranslate Applications

Compiling on UNIX

To compile a libtranslate application, you need to tell the compiler where to find the libtranslate 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 libtranslate
-I/usr/local/include/libtranslate -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include
$ pkg-config --libs libtranslate
-L/usr/local/lib -ltranslate -lgobject-2.0 -lglib-2.0 -liconv

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 libtranslate Hello World, you would type the following:

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

Compiling on UNIX With Autoconf and Automake

To compile a libtranslate application using GNU Autoconf and GNU Automake, insert the following line at the appropriate place in the configure.ac file:

PKG_CHECK_MODULES(LIBTRANSLATE, libtranslate,, [AC_MSG_ERROR([unable to find libtranslate])])

and insert the following lines in the appropriate Makefile.am file:

bin_PROGRAMS = hello
hello_SOURCES = hello.c
hello_CPPFLAGS = $(LIBTRANSLATE_CFLAGS)
hello_LDFLAGS = $(LIBTRANSLATE_LIBS)