2
votes

I am trying to include some dynamic libraries (.so files) for a simple 3D game I am making on linux using C++. These dynamic libraries are for using the Bullet physics engine.

I have very limited knowledge of how use automake and autoconf so any help would be much appreciated.

How might I modify any of the following files to include these dynamic libraries?

Here is my makefile.am:

noinst_HEADERS= BaseApplication.h Physics.h GameApplication.h

bin_PROGRAMS= OgreApp
OgreApp_CPPFLAGS= -I$(top_srcdir)
OgreApp_SOURCES= BaseApplication.cpp Physics.cpp GameApplication.cpp
OgreApp_CXXFLAGS= $(OGRE_CFLAGS) $(OIS_CFLAGS)
OgreApp_LDADD= $(OGRE_LIBS) $(OIS_LIBS)

EXTRA_DIST = buildit makeit
AUTOMAKE_OPTIONS = foreign

Here is my configure.ac:

AC_INIT(configure.ac)
AM_INIT_AUTOMAKE(SampleApp, 0.1)
AM_CONFIG_HEADER(config.h)

AC_LANG_CPLUSPLUS
AC_PROG_CXX
AM_PROG_LIBTOOL

PKG_CHECK_MODULES(OGRE, [OGRE >= 1.2])
AC_SUBST(OGRE_CFLAGS)
AC_SUBST(OGRE_LIBS)

PKG_CHECK_MODULES(OIS, [OIS >= 1.0])
AC_SUBST(OIS_CFLAGS)
AC_SUBST(OIS_LIBS)

AC_CONFIG_FILES(Makefile)
AC_OUTPUT

I also have a buildit file that sets everything in motion:

#!/bin/sh
rm -rf autom4te.cache
libtoolize --force --copy &&  aclocal &&  autoheader &&  automake --add-missing --force-missing --copy --foreign &&  autoconf
./configure && ./makeit
2
Your buildit script is too complex. Do not call libtoolize, aclocal, etc explicitly. Instead, just call autoreconf -i - William Pursell
Your usage of AC_INIT is extremetly antiquated. In modern autoconf, AC_INIT should take 3 arguments: project name, version, point-of-contact. What version of autoconf are you using? - William Pursell
AM_PROG_LIBTOOL should not be used anymore. Use LT_INIT instead. - William Pursell

2 Answers

2
votes

For Bullet, there should be a bullet.pc file installed on your system which you can use with the autocong macro PKG_CHECK_MODULES, the same way OGRE and OIS are included:

# in configure.ac 
PKG_CHECK_MODULES(BULLET, [bullet])

# in Makefile.am
OgreApp_CXXFLAGS= $(OGRE_CFLAGS) $(OIS_CFLAGS) $(BULLET_CFLAGS)
OgreApp_LDADD= $(OGRE_LIBS) $(OIS_LIBS) $(BULLET_LIBS)


# in configure.ac 
PKG_CHECK_MODULES(DEPENDENCIES, [OGRE >= 1.2 OIS >= 1.0 bullet])

# in Makefile.am
OgreApp_CXXFLAGS= $(DEPENDENCIES_CFLAGS)
OgreApp_LDADD= $(DEPENDENCIES_LIBS)

And as Jack Kelly wrote in the comments, if you have pkg-config >= 0.24 (released in 2010), you don't need to use AC_SUBST after PKG_CHECK_MODULE.

0
votes

In your Makefile.am:

OgreApp_LIBADD= -llib1 -llib2

Does that help?

Edit: or try appending -llib1 -llib2 to the OgreApp_LDADD=... line, I'm not sure myself.