User Tools

Site Tools


Checking for a C++ library with Autotools

Check for a C++ library is not always easy using autotools. It is because C++ mangles the symbol names and thus the C++ functions cannot be called from C programs. The solution is to run one's own test.

In the ARTIMAGEN library, most of the methods are part of classes, which are part of a namespace. This and the name mangling are probably the reasons, why the traditional AC_CHECK_LIB macro doesn't work.

This problem can be solved using one's own test. The following example is taken from gAIG's file. It tests for the header file, tries to declare a variable with a library-specific type and finally attempts to link with the library.

LDFLAGS="$LDFLAGS -lartimagen"
 [AC_LANG_PROGRAM([#include <artimagen.h>],
 [IM_STORE_TYPE dummy])],
 [AC_MSG_ERROR([libartiamgen is not installed.])])
programming/cxx_lib_check_autotools.txt · Last modified: 2017/05/16 11:10 (external edit)