Compiling libtranslate Modules

Compiling on UNIX

To compile a libtranslate module, you need to tell the compiler where to find the libtranslate header files. This is done with the pkg-config utility.

For instance, to compile a libtranslate Hello World module, you would type the following:

$ cc `pkg-config --cflags libtranslate` -shared -fPIC hello.c -o hello.so

Compiling on UNIX With Autoconf, Automake and Libtool

To compile a libtranslate module using GNU Autoconf, GNU Automake and GNU Libtool, 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:

modulesdir = $(libdir)/libtranslate/modules
modules_LTLIBRARIES = hello.la
hello_la_SOURCES = hello.c
hello_la_CPPFLAGS = $(LIBTRANSLATE_CFLAGS)
hello_la_LDFLAGS = -avoid-version -module

Module Search Paths

libtranslate loads modules from prefix/libtranslate/modules (where prefix is the prefix where libtranslate is installed) and from ~/.libtranslate/modules (where ~ is the path to your home directory). Filenames not having the system-specific shared object extension (usually .so) are ignored.