Next Previous Contents

3. Adding Extra SDL Add-On Libraries

One of the great things about SDL is the fact that it is very thin and that you can add what functionality you want via the use of add-on libraries.

3.1 General add-on libraries

For most add-on libraries, you can just use the standard AC_CHECK_LIB(..) macro to verify that the library exists. The basic usage upon which many library checks can be based upon looks like the following:


dnl Checks for libraries. 
dnl Replace `main' with a function in -l<SOME_LIB>:
AC_CHECK_LIB(SOME_LIB, 
       main, 
       LIBS="$LIBS -lSOME_LIB", 
       AC_MSG_ERROR([*** SOME_LIB library not found!]) 
)

Here, we replace SOME_LIB with whatever library we are checking for. As an example, here is how we would implement a check for the SDL_image library:


dnl Checks for libraries. 
dnl Replace `main' with a function in -lSDL_image: 
AC_CHECK_LIB(SDL_image, 
       main, 
       LIBS="$LIBS -lSDL_image", 
       AC_MSG_ERROR([*** SDL_image library not found!]) 
)

And an example for SDL_ttf would be:


dnl Checks for libraries. 
dnl Replace `main' with a function in -lSDL_ttf: 
AC_CHECK_LIB(SDL_ttf, 
       main, 
       LIBS="$LIBS -lSDL_ttf", 
       AC_MSG_ERROR([*** SDL_ttf library not found!]) 
)

Simple, right?

Now all you need to do is add these snippets to configure.in, just after where we checked for SDL, and before we create the Makefiles (at the end of configure.in) and regenerate your build files ("Build->Distclean", "Build->Automake & Autoconf", "Build->Configure").

3.2 Add-on libraries which do not fit this scheme

Coming soon


Next Previous Contents