views:

43

answers:

1

I want to use freeglut for my project.

In my configure.ac it looks like this, it worked like this for SDL so I just replaced some potions and hoped it works for freeglut as well but it does not. So what am I doing wrong?

# Check for freeglut
PKG_CHECK_MODULES([FREEGLUT], [freeglut >= 3.0])
AC_SUBST(FREEGLUT_CFLAGS)
AC_SUBST(FREEGLUT_LIBS)

Also what do I have to write into Makefile.am? For SDL it looks like this:

INCLUDES = @SDL_CFLAGS@
LDADD = @SDL_LIBS@
+1  A: 

Pkg-config is a program that looks up the necessary compiler flags and linker flags for a library. PKG_CHECK_MODULES([NAME], [libraries]) is an autoconf macro that looks up the flags for libraries and puts them into two variables, NAME_CFLAGS and NAME_LIBS. Not all libraries support it.

In order to support pkg-config, libraries must install a .pc file. Looking at freeglut's source code it seems that there isn't one, so I conclude it doesn't support pkg-config.

What you should do when a library doesn't support pkg-config, is look at its documentation to see whether it mentions any compiler flags and linker flags you should use. I can't find mention of this anywhere.

Since that fails, the next best thing is just to assume that the library doesn't need any extra compiler flags, and only one linker flag: -l<name>, in this case -lfreeglut. You can also use an autoconf macro to check this for you automatically. You can add this to your configure.ac like so:

AC_CHECK_LIB([freeglut], [glutInit])

This will automatically add -lfreeglut to LIBS if the freeglut library is present, so you shouldn't have to write anything extra in your Makefile.am.

ptomato