daedalic
daedalic

Reputation: 103

Including dynamic libraries using automake and autoconf

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

Upvotes: 2

Views: 690

Answers (2)

alexisdm
alexisdm

Reputation: 29896

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)


If you add more unconditional dependencies, you might want to simplify both files by grouping them like this:

# 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.

Upvotes: 2

Irfy
Irfy

Reputation: 9607

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.

Upvotes: 0

Related Questions