Print

Image

Setting Up An Application using GNU Autotools - Linux
IMPORTANT: These instructions are very old and only work with old releases of Ogre.

 

For recent versions of Ogre, please follow the CMake instructions.


Introduction

This set of instructions will walk you through setting up a C++ project from scratch using GNU Autotools.

When you have finished this tutorial you will be able to compile a working Ogre Application and you will be ready to start the Basic Tutorials.

Prerequisites

You should have a working build environment set up (apt-get install build-essentials on Ubuntu)
Make sure that autoconf + automake + libtool are installed.

Ogre Wiki Tutorial Framework

Download the Ogre Wiki Tutorial Framework

And uncompress it into an empty directory. In the following sections, it is assumed that you are executing the instructions from within that directory.

bootstrap

#!/bin/sh
 rm -rf autom4te.cache
 libtoolize --force --copy &&  aclocal &&  autoheader &&  automake --add-missing --force-missing --copy --foreign &&  autoconf

Make this file (bootstrap) executable.

 

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.9, OGRE-Overlay >= 1.9])
 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

 

Makefile.am

noinst_HEADERS= BaseApplication.h TutorialApplication.h
 
bin_PROGRAMS= OgreApp
 OgreApp_CPPFLAGS= -I$(top_srcdir)
 OgreApp_SOURCES= BaseApplication.cpp TutorialApplication.cpp
 OgreApp_CXXFLAGS= $(OGRE_CFLAGS) $(OIS_CFLAGS)
 OgreApp_LDADD= $(OGRE_LIBS) $(OIS_LIBS)
 
 EXTRA_DIST = bootstrap
 AUTOMAKE_OPTIONS = foreign

 

The Autotools Dance

Run this in a console:

./bootstrap && ./configure && make

 
You should have successfully built your Ogre application. :-)

 

Adding more OGRE libraries

Through out the tutorials you will have to add optional components to the configure.ac file like the OGRE Terrain component in Basic Tutorial 3.

To do this you have first to discover the OGRE libraries available to you. To get that list execute the following command:

pkg-config --list-all | grep OGRE

 
With OGRE 1.7.1 the following list should be displayed:

OGRE-Paging                   OGRE-Paging - General purpose paging component for OGRE
OGRE-PCZ                      OGRE-PCZ - Portal-Connected Zone Scene Manager for OGRE
OGRE-RTShaderSystem           OGRE-RTShaderSystem - Real time shader generation component for OGRE
OGRE                          OGRE - Object-Oriented Graphics Rendering Engine
OGRE-Property                 OGRE-Property - General purpose property component for OGRE
OGRE-Terrain                  OGRE-Terrain - Outdoor terrain component for OGRE

 
To see the options available to you with pkg-config, run:

pkg-config --help

 
An option of interest is --modversion which allow to display the version of the package provided as parameter of the command.

To add the required package to your configure.ac, insert the package name followed by >= and the minimum version of that lib required by your application in the second parameter of PKG_CHECK_MODULES after the text OGRE >= 1.2 between the brackets.

With OGRE-Terrain the code for PKG_CHECK_MODULES will became:

PKG_CHECK_MODULES(OGRE, [OGRE >= 1.2 OGRE-Terrain >= 1.7.1])

 
The file Makefile.am doesn't need to be modified.

Alternatively, instead of concatenating all the OGRE related libraries into one call to PKG_CHECK_MODULES, you can create one instance of PKG_CHECK_MODULES for each library to include in the build process. Like it is done for OGRE and OIS in the configure.ac above.

Below is an example with OGRE-Terrain:

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(OGRE_TERRAIN, [OGRE-Terrain >= 1.2])
 AC_SUBST(OGRE_TERRAIN_CFLAGS)
 AC_SUBST(OGRE_TERRAIN_LIBS)
 
 PKG_CHECK_MODULES(OIS, [OIS >= 1.0])
 AC_SUBST(OIS_CFLAGS)
 AC_SUBST(OIS_LIBS)
 
 AC_CONFIG_FILES(Makefile)
 AC_OUTPUT

 
In that case, you need to modify the Makefile.am accordingly. With the configure.ac above, the corresponding Makefile.am is:

noinst_HEADERS= BaseApplication.h TutorialApplication.h
 
bin_PROGRAMS= OgreApp
 OgreApp_CPPFLAGS= -I$(top_srcdir)
 OgreApp_SOURCES= BaseApplication.cpp TutorialApplication.cpp
 OgreApp_CXXFLAGS= $(OGRE_CFLAGS) $(OGRE_TERRAIN_CFLAGS) $(OIS_CFLAGS)
 OgreApp_LDADD= $(OGRE_LIBS) $(OGRE_TERRAIN_LIBS) $(OIS_LIBS)
 
 EXTRA_DIST = bootstrap
 AUTOMAKE_OPTIONS = foreign

 

Possible Improvements

Make a new build target which either copies the executable to a 'dist' directory - see dflkjf? - or a target which copies the Ogre configuration files (plugins.cfg and resources.cfg) from /usr/local/share/OGRE.

Another improvement would be to search the source code into a subdirectory called src/ and instruct the user to put the Tutorial Framework sources in that location.


Contributors to this page: clemix1 points  , montaropdf61 points  , jacmoe180265 points  , dark_sylinc1400 points  and c6burns837 points  .
Page last modified on Monday 20 of March, 2017 22:06:05 UTC by clemix1 points .


The content on this page is licensed under the terms of the Creative Commons Attribution-ShareAlike License.
As an exception, any source code contributed within the content is released into the Public Domain.