You are on page 1of 57

SettingUpAnApplication

From Ogre Wiki

Jump to: navigation, search

This page is a guide to setting up your first application. Be sure that you've already installed
OGRE by either Installing An SDK or Building From Source. Beginners should use the first
option if available.

Contents
[hide]

· 1 Prerequisites
· 2 Environment Settings
· 3 Create A Project File
o 3.1 Microsoft Visual C++ 6 (SP3+)
o 3.2 Microsoft Visual C++ .NET
o 3.3 Microsoft Visual C++ 2008
o 3.4 Code::Blocks + MinGW 3.4.5 + STLPort 5.0
§ 3.4.1 Project build options
§ 3.4.2 Debug build target options:
§ 3.4.3 Release build target options:
o 3.5 Code::Blocks on Linux
o 3.6 Gnu Compiler Collection (gcc) v3.x (using make)
o 3.7 XCode
o 3.8 Autotools
o 3.9 Scons
§ 3.9.1 Alternate Scons File
o 3.10 Eclipse
o 3.11 Anjuta IDE
o 3.12 KDevelop IDE
o 3.13 Cross compiling Win32 applications in Linux
· 4 Your First Application
· 5 Getting Help

Prerequisites
By this time you should have already worked through Installing An SDK or Building From
Source and have OGRE installed on your system. If not, go back to the appropriate page to finish
configuring your OGRE.
In order to run your application, there are various files that need to be locatable by your system.
The list below details these files. [_d] denotes an optional reference to a debug library (ie
OgreMain_d.dll instead of OgreMain.dll). These files should be in your working directory, or
accessible by an appropriate path.

On Mac OS X, your project must be run from an application bundle (aka ".app"), otherwise Ogre
will not initialise properly. XCode does this for you automatically, but if you don't use XCode
you will have to build the bundle manually.

The easiest way to get everything configured is to copy an existing OGRE sample and the media
directory into your own working directory. If using Windows, copy all the necessary runtime
DLLs to this directory. Edit plugins.cfg and resources.cfg so that the file locations they
contain match this new directory.

OGRE Libraries & Files

· OGRE libraries (OgreMain[_d].dll, libOgreMain.so for linux).


· plugins.cfg - Text file specifying the rendering libraries available to Ogre (ie DX9,
OpenGL).
· All the plugin libraries listed in plugins.cfg (you can remove items from plugins.cfg if
you don't wish to use them).
· resources.cfg - If using the ExampleApplication, a text file specifing paths to materials,
textures, models, etc.
· OgreCore.zip - Ensure resources.cfg has the proper path to this file if you plan to use the
OGRE debug panel or profiler.
· Other Resources used in your program (*.zip; *.png; *.particle; *.mesh; ...).

3rd Party Libraries

The following packages also need to be installed if building from source (not SDK). The libraries
(.lib; .a) and header files (.h) will be required for linking and the runtime libraries (win32 .dll;
linux .so) necessary for running. If on the Windows platform, it is highly recommended to use
the precompiled dependencies available on Source releases. Grab the correct package for your
compiler.

These are required:

· Zlib: zlib1.dll; libz.so (debian: zlib1g, zlib1g-dev)


· Direct X SDK (required for OIS library, which is needed for the examples)

These are optional:

· CEGUI: OgreGUIRenderer[_d].dll, CEGUIBase[_d].dll, CEGUITaharezLook[_d].dll,


CEGUIWindowsLook[_d].dll, xerces-c_2_5_0.dll
· CEGUI: libCEGUIBase.so, libCEGUIOgreRenderer.so, libxerces-c.so (debian: libcegui-
mk2-0, libcegui-mk2-dev, libxerces26, libxerces26-dev)
· Cg: cg.dll; libCg.so (debian: nvidia-cg-toolkit)
· OpenEXR: openexr.dll??; (debian: libopenexr-dev libopenexr2 )
· ReferenceApp: ReferenceAppLayer.dll

Extras for Microsoft Visual C++ 6 (SP3+)

· stlport_vc6[_stldebug]46.dll
· msvcp60[D].dll
· msvcrt[D].dll

Extras for Microsoft Visual C++.Net 2002

· stlport_vc7[_stldebug]46.dll
· msvcp70[d].dll
· msvcr70[d].dll

Extras for Microsoft Visual C++.Net 2003

· msvcp71[d].dll
· msvcr71[d].dll

Extras for Mingw + STLPort

· libstlport[stlg].5.0.dll
· mingwm10.dll

Environment Settings
You may want to register an environment variable pointing at the root of the OGRE installation
so you can express all your paths relative to that. It can be easier if you ever move things around
or onto a different machine. For information on checking and updating environment variables,
see the documentation for Windows, Linux and Mac OSX.

· If you downloaded and installed the precompiled OGRE SDK, you should already have
an environment variable called 'OGRE_HOME' registered already, pointing at the folder
where you installed. If it isn't there you probably installed under a different user, so
define OGRE_HOME manually
· If you downloaded the source distribution, you should register a new environment
variable OGRE_SRC pointing at the 'ogrenew' folder from the OGRE source

Create A Project File


This section is not for extensive compiler/IDE settings. It is only for very short steps to start a
new project. This should be very easy to do in any IDE. The source code that will go into the
project is below. Create a working directory to store your source code. A standard directory
structure separates headers, source files and project files as follows:

work_dir
include
*.h
src
*.cpp
scripts
*.vcproj

Microsoft Visual C++ 6 (SP3+)

Ogre does not provide support for VC6. It's from 1998, and rather old. It does not support ISO
C++. It will only cause you pain.

It's recommended to use Visual C++ 2005 Express (also called VC8) instead.

If you absolutely must use that ancient thing, proceed on your own. You are not going to receive
any support, other than people telling you to upgrade.

Microsoft Visual C++ .NET

Important:

If you use Visual Studio 2005 (VC8) make sure to get service pack #1 to go with it.

Note: If you are using VC++ .NET 2003 or later, you can use the Ogre Application Wizard and
you are ready to create OGRE apps - feel free to skip down to the code section, as the application
wizard will set up the project for you. Also see The Complete Blanks Guide To Using The
OGRE SDK AppWizard.

Otherwise, to manually configure the IDE, follow these steps:

1. Create a new project


2. Choose 'Visual C++ Projects' / 'Win32' then 'Win32 Project'.

3. Enter a name for your project and change the location to point to a work directory
(separate from the runtime directory).
4. Select 'Windows Application' and 'Empty project' when prompted for the type of project
to create.
5. Create a new source file by selecting 'Project -> Add New Item...'. Make sure the file is in
the work directory. This step must be performed before editing project properties
(otherwise the 'C/C++' page will be unavailable).
6. Save the project.

If you named your project "Testproject" and selected a location like C:\Work, and checked the
box called "Create directory for solution", with a solution name of "Testsolution", then the
directory structure will be: C:\Work\Testsolution\Testproject. If you do not create a directory for
the solution, the structure will simply be: C:\Work\Testproject.

To clarify where the DLL files should be, an easy way is to copy the \bin folder (containing
\debug and \release) and the \media folder from the OGRE installation directory to your
Testproject folder (note: in this case you might be copying DLLs that won't be needed, but it's
the hassle-free way). If you follow the convention presented above and you created folders for
the header, scripts and source files, you have the following folders under \Testproject (excluding
subfolders): 'bin', 'include', 'media', 'testsolution', 'scripts', and 'src'. However, if you don't want to
copy them while running your Testproject from Visual Studio just add the path to OGRE's DLL
files to the %PATH% global environment variable like this:

Debugging : Environment =
PATH=%PATH%;%OGRE_HOME%\bin\debug

and for the release version

Debugging : Environment =
PATH=%PATH%;%OGRE_HOME%\bin\release

This will not modify the %PATH% environment variable permanently, just for the given run, so
its safer. You could modify it globally for all windows applications like this:

My Computer -> Properties -> Advanced -> Environment Variables -> System
Variables -> Path += ;%OGRE_HOME%\bin\debug

or

My Computer -> Properties -> Advanced -> Environment Variables -> System
Variables -> Path += ;%OGRE_HOME%\bin\release

but this could lead to confusion if working with different Ogre versions and is not recommended.

If you follow the next few steps carefully, your project should compile without errors.

Configure your project with the following settings. All of these are for the Debug configuration.
To set up the Release configuration just change the directories from '\Debug\' to '\Release\'.
Select "project properties" and under "configuration properties" add the following:
Debugging : Command =
$(OutDir)\$(ProjectName).exe
Debugging : Working Directory = $(OutDir)
C/C++ : Preprocessor : Preprocessor Definitions += _STLP_DEBUG (only in Debug
mode, not needed for .Net 2003 and 2005)
C/C++ : Code Generation : Use runtime library = Multithreaded Debug
DLL (Multithreaded DLL in Release)
Linker : General : Output File =
..\bin\Debug\[appname].exe
Linker : Input : Additional Dependencies += OgreMain_d.lib
OIS_d.lib (OgreMain.lib OIS.lib in Release)

If you also use CEGUI, you need to tell Visual Studio to link the libs by doing this:

Linker : Input : Additional Dependencies += CEGUIBase_d.lib


OgreGUIRenderer_d.lib (CEGUIBase.lib OgreGUIRenderer.lib in Release)

And, for those using the SDK:

C/C++ : General : Additional Include Directories =


..\include;$(OGRE_HOME)\include;$(OGRE_HOME)\samples\include
Linker : General : Additional Library Directories = $(OGRE_HOME)\lib

Or, for those using the source release:

C/C++ : General : Additional Include Directories =


..\include;$(OGRE_SRC)\OgreMain\include;$(OGRE_SRC)\Samples\Common\Include
Linker : General : Additional Library Directories =
$(OGRE_SRC)\OgreMain\Lib\Debug

Additional hints on getting your application to run from within the IDE:
Visual Studio Debugging Settings

Microsoft Visual C++ 2008

Reserved for Microsoft Visual C++ 2008 setup instructions.

Code::Blocks + MinGW 3.4.5 + STLPort 5.0

Have a look at the build options for Demo_CameraTrack, most of the demos use the same build
options.

Note: with MinGW gcc 3.4.5 you can link directly against dll's built by gcc 3.4.5 and do not
require an import lib. This is the same setup on Linux where you link directly to the shared
object (.so). This is why the SDK does not come with import libs for Ogre. You don't need them.

Build options that you should use:

Normally you will have two targets: Debug and Release.


To create a new target:

1. Right click on the project in the Management window and select Properties in the popup
and this will open up the properties window for your project.
2. Select the Target tab.
3. Select Add to define a new target.
4. Type in the target name ie Debug.
5. Select OK.

Select Build Options to modify build options for a target.

Project build options

will be used for both Debug and Release target build options:

ensure Selected compiler is: GNU GCC Compiler

· Compiler
o Other options
§ -mthreads
§ -fmessage-length=0
§ -fexceptions
§ -fident
o '#defines'
§ _STLP_NO_CUSTOM_IO
If your app does not define any custom IO templates then this define will
speed up compiles.
§ _STLP_USE_DYNAMIC_LIB
this ensures that the DLL version of STLPort is used.
· Linker
o Other linker options:
§ -Wl,--enable-auto-image-base
§ -Wl,--add-stdcall-alias
· Directories
o Compiler
§ $(OGRE_HOME)\stlport\stlport
VERY IMPORTANT: The stlport include directory has to be first in the
include directories. If it is not then headers used for libstdc++ could get
included which will cause conflicts with stlport during the link stage. You
will most likely get undefined reference error messages with member
methods saying they require std::string (method parameters). You should
never see std:: in an error message and if you do then it means that the
STLPort headers were not found and libstdc++ headers were used instead.
If you do end up in this scenerio, after you correct the directory problem
you must do a rebuild so that everything gets recompiled with the proper
headers. Selecting build won't do it since CB will just attempt to do the
link stage again since it doesn't detect any changes in the source and will
fail again.
§ $(OGRE_HOME)\include
§ Your project include directories
o Linker
§ $(OGRE_HOME)\bin\$(TARGET_NAME)
this is the path to OgreMain.dll or OgreMain_d.dll along with
stlport.5.0.dll or stlportstlg.5.0.dll depending on TARGET_NAME state.
$(TARGET_NAME) is a built in Code::Blocks macro that you can use in
your project settings. It gives you the active project target build name.

Debug build target options:

ensure Selected compiler is: GNU GCC Compiler


set Policy to 'Append target options to project options'
· Compiler
o '#defines'
§ WIN32
§ _DEBUG
§ _WINDOWS
§ _STLP_DEBUG
this tells STLPort to use the special debug build version of the dll
· Linker
o Link libraries:
§ Your project dll's or static libs (.a)
§ OgreMain_d
this is the name of the debug build of OgreMain dll.
§ stlportstlg.5.0
this must be the last entry

Release build target options:

ensure Selected compiler is: GNU GCC Compiler


set Policy to 'Append target options to project options'

· Compiler
o '#defines'
§ WIN32
§ NDEBUG
§ _WINDOWS
· Linker
o Link libraries:
§ Your project dll's or static libs (.a)
§ OgreMain
this is the name of the release build of OgreMain dll.
§ stlport.5.0
this must be the last entry

Note: OGRE_HOME is a pre-defined environment variable setup by the SDK installer.


OGRE_HOME points to the directory where the SDK is installed. You can use
$(OGRE_HOME) within your build options when setting up paths to specific directories with
the SDK that you will need to access.

WARNING Do not mix dll and static object builds using different STL implementations. Here
is an example: You build a dll using stdlibc++ but your exe is built using STLPort. Everything
that is c++ must be built using STLPort. This does not apply to C static libs and dll's.

Code::Blocks on Linux

See section 5 of the tutorial on the Ubuntu forums here.


Gnu Compiler Collection (gcc) v3.x (using make)

Make sure you are using gcc 3.x. Many Linux distributions still come with gcc 2.95.x which
does not have as good support for the ISO C++ standard and will probably cause you problems.
Please install the latest stable version of gcc 3.x.

Create a file called 'Makefile' in your application folder, with the following contents. Later you
can replace SampleApp with your own program file name.

DEFINES =
LIBS = OGRE
CXX = g++
CXXFLAGS = $(shell pkg-config --cflags $(LIBS)) $(DEFINES)
LD = g++
LDFLAGS = $(shell pkg-config --libs $(LIBS))

all:
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o SampleApp SampleApp.cpp

clean:
rm -f SampleApp

When you are ready to start working with multiple files and even incorporating CEGUI, your
Makefile might look like the following example. Make will expect to find SampleApp.cpp,
camera.cpp and listener.cpp:

## Compiler and linker settings


DEFINES = -g
LIBS = OGRE CEGUI-OGRE CEGUI
CXX = g++
CXXFLAGS = $(shell pkg-config --cflags $(LIBS)) $(DEFINES)
LD = g++
LDFLAGS = $(shell pkg-config --libs $(LIBS))

## Files to include in yourApp project


SAMPLEAPP = SampleApp.o camera.o listener.o

## Compilation and linking occurs here


all: SampleApp
$(LD) $(LDFLAGS) $(SAMPLEAPP) -o SampleApp

SampleApp: $(SAMPLEAPP)

## Clean up
clean:
rm -f $(SAMPLEAPP) SampleApp

XCode

· In XCode, select menu File > New project > Carbon Application.
· Place your project wherever you want and name it, then click finish
· Remove main.nib and *_Prefix.pch (note: if you wish to use a precompiled prefix header,
you may, just adapt the instructions as needed)
· rename main.c to main.cpp. Remove its content and replace it with Ogre code (for
instance http://www.ogre3d.org/wiki/index.php/BasicTutorial2Source).

· Add Ogre.framework and Cg.framework to your project by right-clicking on your project


name in the tree and selecting Add > Existing frameworks. Add the IOKit framework
from system directories the same way.
· Add static library libois.a the same way (libFreeImage.a, libfreetype.a libzzip.a were also
previously required but apparently are no more).

(These libraries are all provided in the Ogre dependencies download except Ogre.framework
that you either got from the mac SDK or built from source.) (As of Ogre 1.4.5, I had better
success with the CVS version of OIS on mac. OIS versions greater than 1.0 should be all okay
though.)

Now you must add the required config files to your project. You can find these files in
Ogre/Mac/Samples/config Just drag and drop them to the file tree and they should automatically
be copied to the Resources directory of your app. Whenever you add data or source files to the
project, make sure you check the copy items checkbox in the dialog that pops-up before
confirming file addition because you don't want to modify the original files. There is no
need to do that with libraries though.

· plugins.cfg
· media.cfg
· resources.cfg : you will need to edit this one to point inside your application. here is an
example of resources.cfg file to work with the samples and tutorials

# Resource locations to be added to the 'boostrap' path


# This also contains the minimum you need to use the Ogre example framework
[Bootstrap]
Zip=Contents/Resources/Media/packs/OgreCore.zip

# Resource locations to be added to the default path


[General]
FileSystem=Contents/Resources/Media
FileSystem=Contents/Resources/Media/fonts
FileSystem=Contents/Resources/Media/materials/programs
FileSystem=Contents/Resources/Media/materials/scripts
FileSystem=Contents/Resources/Media/materials/textures
FileSystem=Contents/Resources/Media/models
FileSystem=Contents/Resources/Media/overlays
FileSystem=Contents/Resources/Media/particle
FileSystem=Contents/Resources/Media/gui
FileSystem=Contents/Resources/Media/DeferredShadingMedia
Zip=Contents/Resources/Media/packs/cubemap.zip
Zip=Contents/Resources/Media/packs/cubemapsJS.zip
Zip=Contents/Resources/Media/packs/dragon.zip
Zip=Contents/Resources/Media/packs/fresneldemo.zip
Zip=Contents/Resources/Media/packs/ogretestmap.zip
Zip=Contents/Resources/Media/packs/skybox.zip

· Media : found in Ogre/Samples (if you want to run the samples or tutorials. make sure
you create folder references and not group references - you can choose that in the dialog
that pops-up just after you dragged and dropped the folder onto the tree)

· Open targets in the file tree


· Right-click on your target, select get info, go in tab build
· In configuration, make sure to select all configurations when you make changes that
should apply to both debug and release
· In collection architectures, double-click on element Architectures in the list and select
the architectures you wish to build (and have built Ogre for). If you build Universal
binary, make sure the SDK path in build locations is a universal one (for instance
/Developer/SDKs/MacOSX10.4u.sdk. This template should set it to universal by
default.).
· In linking, disable ZeroLink
· In language, remove the file in Prefix Header and uncheck Precompile prefix header
· In search paths, add the path to includes provided in Ogre dependencies (double-click on
header search paths, drag and drop the OgreDependencies-1.4.5/include folder there)
o Note: Be sure to leave the "Recursive" check box unchecked, otherwise you may
experience compiler errors. (ex:
http://www.ogre3d.org/phpBB2/viewtopic.php?p=279172#279172)

Existing projects will try to include Ogre.h and not <Ogre/Ogre.h> like frameworks usually
require, so you may want to set up an additional header search path pointing inside your Ogre
framework headers directory.

If you want to use the samples or tutorials you will also need to copy example application header
files from /ogre-1.4.5/Samples/Common/include/

You will now need a copy files build step in your target:

· Right-click on your target


· select Add > New Build Phase > New Copy File Build Phase
· In the window that pops up, select Frameworks in the destination field, don't change any
other settings.
· Now expand your target in the tree view and you should see the new step you just added
as a child of your target, by befault named something like Copy Files.
· Drag and drop all Ogre-related frameworks (including those from Ogre dependencies)
inside the new build step you just created.
· Warning, files you add to the project from now on will tend to add themselves to the copy
files build step, make sure only frameworks find their way there.
You are now ready to build and run!

Once you're done, put a copy of your project in ~/Library/Application


Support/Developer/Shared/Xcode/Project Templates/Application/, so next time you can just
select New project and choose this one from the template list (in older versions of OSX/Xcode,
the templates directoy was at ~/Library/Application Support/Apple/Developer Tools/Project
Templates)

Autotools

To build your application using the ubiquitous GNU autotools (autoconf + automake + libtool),
create these files in your project folder with the following content:

bootstrap
#!/bin/sh
rm -rf autom4te.cache
libtoolize --force --copy && \
aclocal && \
autoheader && \
automake --add-missing --force-missing --copy --foreign && \
autoconf
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 include/Makefile src/Makefile)


AC_OUTPUT
Makefile.am
SUBDIRS = include src
EXTRA_DIST = bootstrap
AUTOMAKE_OPTIONS = foreign
include/Makefile.am
noinst_HEADERS= SampleApp.h
src/Makefile.am
bin_PROGRAMS= SampleApp
SampleApp_CPPFLAGS= -I$(top_srcdir)/include
SampleApp_SOURCES= SampleApp.cpp
SampleApp_CXXFLAGS= $(OGRE_CFLAGS) $(OIS_CFLAGS)
SampleApp_LDADD= $(OGRE_LIBS) $(OIS_LIBS)
See Your First Application or Minimal Application to create include/SampleApp.h and
src/SampleApp.cpp.
You probably want to add plugins.cfg and resources.cfg to the executable folder (src) (see
Prerequisites).

To build your app run ./bootstrap && ./configure && make. Subsequent builds only need
running make.
To execute your app go to the src folder and run ./SampleApp.

Scons

Scons is a multiplatform building tool programmed in Python, designed to replace GNU Make
and other similar tools (autoconf, automake, etc).

For compiling using scons, you'll only need to type:

scons

in your command line. The scons building tool will automatically check for all needed libraries
and include files in your system before trying to compile.

For using scons, you'll need to create a SConstruct file. You'll had to pay a visit to scons.org to
learn the directives for building with that tool. But here we provide a sample SConstruct file, that
will build both in Ubuntu Linux and in Windows (using Visual Studio 2003 at least).

For a simple program composed by a file named main.cpp, using Ogre Eihort and OIS, this
would be the SConstruct file needed:

platform = ARGUMENTS.get('OS', Platform())


mode = ARGUMENTS.get('mode', "release")

if platform.name == "linux":
listinc=[
# our main include directory
'include',

# location of ogre includes


'/usr/local/include/OGRE',
# location of ois includes
'/usr/local/include/OIS',
]
else:
listinc=[
# our main include directory
'include',

# location of ogre includes


'E:/ogre-eihort/ogrenew/OgreMain/include',
# location of ois includes
'E:/ogre-eihort/ogrenew/Dependencies/include/OIS',
]
if platform.name == "linux":
debugcflags=['-g']
releasecflags=[]

if mode=="debug":
env=Environment(CPPPATH=listinc, LIBPATH='.', CCFLAGS = debugcflags)
else:
env=Environment(CPPPATH=listinc, LIBPATH='.', CCFLAGS = releasecflags)
else:
debugcflags = ['-W1', '-GX', '-EHsc', '-D_DEBUG', '/MDd', '/Zi'] #extra
compile flags for debug
releasecflags = ['-O2', '-EHsc', '-DNDEBUG', '/MD'] #extra compile
flags for release

if mode=="debug":
env=Environment(CPPPATH=listinc, LIBPATH='bin/windows/debug'
, CCFLAGS = debugcflags, CPPDEFINES=["WIN32", "_DEBUG",
"_WINDOWS"], LINKFLAGS='/DEBUG'
)
else:
env=Environment(CPPPATH=listinc, LIBPATH='bin/windows/release'
, CCFLAGS = releasecflags, CPPDEFINES=["WIN32", "NDEBUG",
"_WINDOWS"]
)

# check for required include files and libraries


conf = Configure(env)
if not conf.CheckCXXHeader('Ogre.h'):
print 'Ogre must be installed!'
Exit(1)
if not conf.CheckCXXHeader('OISPrereqs.h'):
print 'OIS must be installed!'
Exit(1)
if platform.name == "linux":
if not conf.CheckLib('OgreMain'):
print 'OgreMain library must be in path'
Exit(1)
if not conf.CheckLib('OIS'):
print 'OIS library must be in path'
Exit(1)

# list of files needed for compiling the program


main_program_list=Split("""
src/main.cpp
""")

if platform.name == "linux":
# list of libraries needed for linking
libs_list=Split("""
OgreMain
OIS
""")
else:
# list of libraries needed for release
libs_release_list=Split("""
c:/ogre-eihort/ogrenew/OgreMain/lib/Release/OgreMain
c:/ogre-eihort/ogrenew/Dependencies/lib/Release/OIS
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
comdlg32.lib
advapi32.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
odbc32.lib
odbccp32.lib
""")
# list of libraries needed for debug
libs_debug_list=Split("""
c:/ogre-eihort/ogrenew/OgreMain/lib/Debug/OgreMain_d
c:/ogre-eihort/ogrenew/Dependencies/lib/Debug/OIS_d
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
comdlg32.lib
advapi32.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
odbc32.lib
odbccp32.lib
""")

if platform.name == "linux":
if mode=="debug":
env.Program('bin/linux/debug/main_d', main_program_list,
LIBS=libs_list, LIBPATH='.')
else:
env.Program('bin/linux/release/main', main_program_list,
LIBS=libs_list, LIBPATH='.')
else:
if mode=="debug":
env.Program('bin/windows/debug/main_d', main_program_list,
LIBS=libs_debug_list, LIBPATH='.')
else:
env.Program('bin/windows/release/main', main_program_list,
LIBS=libs_release_list, LIBPATH='.')

You might need to change the file paths in the file though.

Use:
· Put your main.cpp file in directory src; create the following empty directories:

include
bin/windows/debug
bin/windows/release
bin/linux/debug
bin/linux/release

· In linux, write any of the following lines in the command line:

scons OS=linux mode=debug # build in debug mode


scons OS=linux # build in release mode
scons OS=linux mode=debug -c # clean in debug mode
scons OS=linux -c # clean in release mode

In windows, use the following lines:

· For debug build:

scons MSTOOLKIT=yes OS=windows mode=debug

· For release build:

scons MSTOOLKIT=yes OS=windows

· For debug clean:

scons MSTOOLKIT=yes OS=windows mode=debug -c

· For release clean:

scons MSTOOLKIT=yes OS=windows -c

Alternate Scons File

Please actually read this file, it's easy to understand and will require some modification for use.

# A Linux Ogre/CEGUI/OIS/OgreOde build Script by Grey, with many thanks to


keir from #scons on freenode.

# Setup our Build Environment, Smarter scripts might be able to change this
at the command line,
env = Environment(
CCFLAGS='-ggdb -pg -g3 -DEXT_HASH',
LDFLAGS='-pg'
)

# Our External Libs


# Got some fugly stuff ( || true ) in there to supress unreadable crashes, it
# ends up using the nicer formatted error messages below
env.ParseConfig('pkg-config --silence-errors --libs --cflags OGRE || true')
env.ParseConfig('pkg-config --silence-errors --libs --cflags OIS || true')
env.ParseConfig('pkg-config --silence-errors --libs --cflags CEGUI-OGRE ||
true')
env.ParseConfig('pkg-config --silence-errors --libs --cflags OgreOde_Core ||
true')

# Get out current config so we can verify we have everything we need.


# There is an autoadd method here, but then we'd have to specify full paths
for
# the libs and headers, which is lame.
config = Configure(env);

# Everyone needs OIS :)


if not config.CheckLibWithHeader('OIS', 'OISPrereqs.h', 'C++'):
print 'OIS must be installed!'
Exit(1)

# this should work to get Ogre included


if not config.CheckLibWithHeader( 'OgreMain', 'Ogre.h', 'C++' ):
print "Ogre Must be installed!"
Exit(1)

# Any other component libraries you use can be added and tested in this
manner
if not config.CheckLibWithHeader( 'OgreOde_Core', 'OgreOde_Core.h', 'C++'):
print 'OgreOde must be installed!'
Exit(1);

# Substitute with your GUI of choice


if not config.CheckLibWithHeader('CEGUIBase', 'CEGUI.h', 'C++'):
print "You need CEGUI to compile this program"
Exit(1);

if not config.CheckLibWithHeader('CEGUIOgreRenderer', 'OgreCEGUIRenderer.h',


'C++'):
print "You need OGRE-CEGUI to compile this program"
Exit(1);

# Validate the configuration and assign it to our env


env = config.Finish();

# Build our main program


env.Program(
target = 'main',
# Replace these with your source files of course
source = [
'main.cpp', 'GUISystem.cpp', 'EventQueue.cpp', 'InputManager.cpp',
'CommandListener.cpp', 'CameraController.cpp', 'KeyMap.cpp',
'OdeManager.cpp', 'PhysModel.cpp', 'ODECharacterController.cpp',
'RayCharacterController.cpp',
'ChaseCameraController.cpp'])

Eclipse

See the Eclipse setup pages for Ogre IDE Eclipse.


Anjuta IDE

A complete working project and sample can be found here: http://waxor.com/page/ogre-


dome.tgz

1. Create a new Generic/Terminal App project.


2. Choose c++ and Executable target when prompted.
3. Delete all of the included template code in main.cc. It will be replaced with the sample
code below.
4. Go to the Settings Menu and choose Compilier and Linker Settings.
5. Open the following tabs and add each entry one line at a time: replace $OGRE_HOME/
with the full path to the ogrenew folder you compiled from. Also note you may have
Ogre in /usr/local/include and /usr/local/lib depending on how you installed it.

Include Paths:
$OGRE_HOME/Samples/Common/include
/usr/include/OGRE (Not necessary if you include like
this '#include <OGRE/Ogre.h>')
/usr/include/CEGUI
/usr/include/OIS
Library paths:
/usr/local/lib
Libraries:
OgreMain
CEGUIBase
CEGUIOgreRenderer
OIS
Options
check "Enable Debugging" (adds -g to the command line)
Options | Compilier flags (CFLAGS):
-DEXT_HASH

KDevelop IDE

KDevelop is a nice flexible IDE for Linux, and it is easy to set up with OGRE.

· Create a new C++ "Simple Hello world program" project.

· Open "configure.in" and add the following line above the AC_OUTPUT statement.

PKG_CHECK_MODULES(OGRE, [OGRE >= 1.2.0])

· Open "src/Makefile.am" and add the following lines.

LDADD = @OGRE_LIBS@
AM_CXXFLAGS = @OGRE_CFLAGS@

· To avoid linker errors, add these lines to src/Makefile.am


sampleapp_LDADD = /usr/local/lib/libOIS.so \
/usr/local/lib/libOgreMain.so

· You may need to change /usr/local/lib/ to the location of your OGRE/OIS libs. Also, you
if you get errors about missing libs later, you will have to link/copy them to /lib or /lib64.

· You may wish to have the program run in the sample apps directory when debuging so
you do not have to copy all the runtime resource files over. To do this go into project
options (top menu) then click run options, then select the custom directory option and put
in "<insert ogre root dir here>/Samples/Common/bin/"

· If you choose to derive your application from the ExampleApplication class that comes
with OGRE, open the automake manager, right click on your target, choose "Add
Existing Files..." and add the files ExampleFrameListener.h and ExampleApplication.h
from ogrenew/Samples/Common/include.

· You also need to tell KDevelop where to find the OGRE specific headers. Click on
Project->Project Settings->Configure Options, click on the C++ tab and add the
following line to "Compiler flags (CXXFLAGS)" :

-I <insert ogre root dir here>OgreMain/include -I <insert ogre root dir


here>OgreMain/include/GLX

· Insert the SampleApp code below for the application, build and run the project.

· To use the debugger, open the projects options, choose the debugger tab and select
"Enable separate terminal for application IO".

Cross compiling Win32 applications in Linux

How to compile applications for MS Windows platform from within Linux: Article.

Your First Application


Now we will create a basic source file for starting an OGRE application. This program, like the
included samples, uses the example framework.

Copy the following code and include it as a new file in your project settings. Following our
conventions, you'd put it in work_dir/src and name it SampleApp.cpp. Since this is dependent
upon ExampleApplication.h and ExampleFrameListener.h make sure these files are accessible by
your project. Our convention would have you put them in work_dir/include. You can copy them
from the Samples directory.

#include "ExampleApplication.h"

// Declare a subclass of the ExampleFrameListener class


class MyListener : public ExampleFrameListener
{
public:
MyListener(RenderWindow* win, Camera* cam) : ExampleFrameListener(win,
cam)
{
}

bool frameStarted(const FrameEvent& evt)


{
return ExampleFrameListener::frameStarted(evt);
}

bool frameEnded(const FrameEvent& evt)


{
return ExampleFrameListener::frameEnded(evt);
}
};

// Declare a subclass of the ExampleApplication class


class SampleApp : public ExampleApplication
{
public:
SampleApp()
{
}

protected:
// Define what is in the scene
void createScene(void)
{
// put your scene creation in here
}

// Create new frame listener


void createFrameListener(void)
{
mFrameListener = new MyListener(mWindow, mCamera);
mRoot->addFrameListener(mFrameListener);
}
};

#ifdef __cplusplus
extern "C" {
#endif

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32


#define WIN32_LEAN_AND_MEAN
#include "windows.h"
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
#else
int main(int argc, char **argv)
#endif
{
// Instantiate our subclass
SampleApp myApp;
try {
// ExampleApplication provides a go method, which starts the
rendering.
myApp.go();
}
catch (Ogre::Exception& e) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBoxA(NULL, e.getFullDescription().c_str(), "An exception has
occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
std::cerr << "Exception:\n";
std::cerr << e.getFullDescription().c_str() << "\n";
#endif
return 1;
}

return 0;
}

#ifdef __cplusplus
}
#endif

Compile this code now. However before running the program, make sure you have a plugins.cfg
and a resources.cfg in the same directory as the executable. Review the Prerequisites section for
the purpose of these files. Edit them and make sure the paths are correct. Otherwise your OGRE
setup dialog box may not have any rendering libraries in it, or you may recieve an error on your
screen or in Ogre.log that looks something like this:

Description: ../../Media/packs/OgreCore.zip - error whilst opening archive:


Unable to read zip file

When the program starts it will display the OGRE setup dialog and start the application with a
blank, black screen containing little more than the OGRE logo and an FPS (frame per second)
display. We haven't added anything to this scene yet, as evidenced by the empty createScene
method. Press ESC to quit the application.

If you didn't get this, something is not right in your setup. See the Prerequisites and the Getting
Help sections to review your installation.

The ExampleApplication framework will boot the OGRE system, displaying a configuration
dialog, create a window, setup a camera and respond to the standard mouselook & WSAD
controls. All you have to do is to fill in the 'createScene' implementation. If you want to do more
advanced things like adding extra controls, choosing a different scene manager, setting up
different resource locations, etc, you will need to override more methods of ExampleApplication
and maybe introduce a subclass of ExampleFrameListener.

As mentioned before, you don't have to use the ExampleApplication and ExampleFrameListener
base classes. Use them to work through the tutorials and to test things out. For larger projects
you'll want to write your own framework, or use one of the frameworks or engines available on
Projects using OGRE.
Note for American readers

Sinbad the lead developer and creator of OGRE, is British. Naturally he uses British spellings
such as "Colour", "Initialise" and "Normalise". Watch out for these spellings in the API.

See below to learn about your resources for getting help. Then your next step is to work through
the Ogre Tutorials.

Getting Help
Probably the top two problems people have with Ogre are not being able to compile or a missing
dependency. For the first, you are going to need to learn how to use your compiler. If you barely
know C++ then expect a challenge, but don't give up! Thousands of people have successfully
gotten Ogre to work with both the GCC and MSVC compilers, so look in the wiki and forums
for what they have done that you haven't. For missing dependencies, these are libraries that aren't
installed, that aren't linked against your program, or that aren't in your runtime path. Other
dependencies are incorrect rendering plugins in your plugins.cfg file or incorrect paths in your
resources.cfg file, or missing one of the files all together.

If you have problems reread this page as well as Installing An SDK and Building From Source
and look in the Ogre.log file. You may also find your problem answered in the Build FAQ. If
you need further help, search the forums. It is likely your problem has happened to others many
times. If this is a new issue, read the forum rules then ask away. Make sure to provide relevant
details from your Ogre.log, exceptions, error messages, and/or debugger back traces. Be specific
and people will be more able to help you.

Retrieved from "http://www.ogre3d.org/wiki/index.php/SettingUpAnApplication"


Table of contents
· Introduction
· Prerequisites
· Tutorial
o Creating a new project
o Creating the directory structure and adding files
o Setting up the environment
o Building the project
o Copying the config files from OGRE_HOME to the project

o Running the project

Introduction
This set of instructions will walk you through setting up a Visual Studio C++
project from scratch. An alternative to this tutorial is to use the Ogre
Application Wizard instead. This tutorial is still useful if you wish to
understand what the Application Wizard does for you. 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
· Visual Studio 2008 must be installed. Visual Studio Downloads
· The Ogre SDK version 1.7 or greater must be installed.
o Installing the Ogre SDK: No SDK install yet
o Build Ogre from source with CMake: CMake Quick Start Guide If
you are building Ogre from source, you must build the debug and
release targets and execute the Install script for both targets as
well. This will create a directory structure that is identical to the
binary install structure.

Tutorial
Creating a new project
· Start Visual Studio 2008
· Create a new project: File | New | Project
· Under project types select Visual C++ then under Templates select
Win32 Project.
· Navigate to the location in which your project will be located by clicking
the Browse button. It should not be in either the SDK directory or in
the source files for Ogre. Type OgreTemplate in the Name field. The
name is is important in the case of this tutorial since you will be copying
a file that matches that name into your project. Later, if you re-use this
template, you can rename it to whatever you want.
· Click the OK button and the Win32 Application Wizard will be displayed.

· Click the Next Button.


· Select 'Windows Application' and 'Empty project' when prompted for the
type of project to create.
· Click the Finish button.

Creating the directory structure and adding files


This tutorial comes with zip file that contains the source, header, and
windows resource files necessary to create a Ogre Application in windows.
These files are the same files created by the Ogre Application Wizard. Don't
worry about the specifics of any one file since the tutorials will use the same
set and will cover what is in each file and teach you how to make your own
framework once you outgrow this basic framework. The files are stored in a
zip file and need only be extracted into your project directory making sure to
keep the supplied directory structure.

· Click here OgreTemplate.zip to download the zip file.


· Extract the files into your project folder.

· If you hover over the second button in the Solution Explorer's toolbar,
you will see that it says "Show all files" It should not currently be
toggled so you should click on it to toggle it. Now you will see this
display of Solution Explorer.
· Open each of the folders by clicking on the + signs to the left of each
folders name.
· Right click on the each of the files and select Include In Project.
· Select File|Save All from the Visual Studio menu.

Setting up the environment

Sometimes Visual Studio will not recognize the project type being built until it
has been compiled once. It is a good idea to compile this project before
proceeding. The downside of this compile is that it will create a folder
underneath the main project folder. Feel free to remove that folder after
completing the tutorial. The Folder will probable be named DEBUG.

· Right click on the project OgreTemplate and select build and then ignore
the errors

· Right click on the project OgreTemplate and select properties. The


following screen will be displayed.
The Properties Pages are arranged in a hierarchy. I will refer to this hierarchy
and separate the levels with the '|' character rather than show screen shots
of each set of variables, . By default, Visual Studio creates two
configurations. The project is created with two configurations: Debug and
Release. You will notice in the upper left corner of the last screen shot that
the "Debug" configuration is currently the active configuration. You can
change which configuration is being shown by selecting the arrow in that
drop-down box. There is an additional value in that drop-down box that
indicates that you wish to change a property in all configurations called,
surprisingly enough, All Configurations. Again I would like to point out that
I am describing configurations that assume you have either installed the SDK
or built, and installed the SDK from source. This tutorial also assumes that
the operating system environment variable OGRE_HOME has been set up to
point to the SDK directory.

· Select the All Configurations Configuration by selecting the


Configuration drop-down box and selecting "All configurations". Set the
variables according to the following chart. You should click __ Apply
after each group of properties.

General | Output Directory : bin\$(ConfigurationName)


General | Intermediate Directory : obj\$(ConfigurationName)
General | Character Set : Use Multi-Byte Character Set

Debugging | Command :
bin\$(ConfigurationName)\$(ProjectName).exe
Debugging | Working Directory : bin\$(ConfigurationName)
Debugging | Environment :
path=$(OGRE_HOME)\Bin\$(ConfigurationName)

C/C++ | General | Additional Include Directories :


include;$(OGRE_HOME)\include\OIS;$(OGRE_HOME)\include\OGRE

Linker | General | Additional Library Directories :


$(OGRE_HOME)\lib\$(ConfigurationName)

· Select the Debug Configuration by selecting the Configuration drop-


down box and selecting "Debug". Set the properties according to the
following chart.
Linker | Input | Additional Dependencies : OgreMain_d.lib
OIS_d.lib
Linker | Debugging | Generate Debug Info : Yes (/DEBUG)

· Select the Release Configuration by selecting the Configuration drop-


down box and selecting "Release". Set the properties according to the
following chart.

Linker | Input | Additional Dependencies : OgreMain.lib OIS.lib


Linker | Debugging | Generate Debug Info : No

Building the project


· Choose the Debug Solution Configuration.
· Right click on the project OgreTemplate and select Build Project.

There should be no compile or link errors.


· Choose the Release Solution Configuration.
· Right click on the project OgreTemplate and select Build Project.

There should be no compile or link errors.


Copying the config files from OGRE_HOME to the project
As a final step we need to copy some additional files that will be needed to
run this project. The build steps just performed created a folder in the project
folder called bin and underneath that folder two folders called release and
debug. Each of these folders acts as the working directory for their
respective configurations when Ogre runs. The Ogre framework will be
looking in the working directory for some configuration files and they will be
slightly different depending on whether a debug or release version is being
run. The configuration files that you will need to run each version are located
in $(OGRE_HOME)\bin\debug and $(OGRE_HOME)\bin\release. Copy
the *.cfg files from the OGRE_HOME directory to the corresponding project
directory.

Running the project


· Run each version of the Project. If it all works correctly, you will see a
Ogre's head. If not, go back and verify that you entered all the project
properties correctly. You can move around with the cursor keys or the W
A S D keys. The mouse will change your facing. You are now ready to
move on to the basic tutorials.
HowTo: Install and Use OGRE

Here's a quick guide I wrote up for installing OGRE on Ubuntu. I hope it's useful.

1 Installing OGRE

1.0 Install Dependencies


Execute the following in a terminal window:
Code:
sudo apt-get install build-essential autoconf libtool libdevil-dev libfreeimage-dev
libfreetype6-dev libglew1.5-dev libxaw7-dev libxrandr-dev libxt-dev libxxf86vm-dev libzzip-dev

In case you're curious, the dependencies are as follows:


Bootstrap: autoconf libtool
Make: build-essential
Ogre: libdevil-dev libfreeimage-dev libfreetype6-dev libglew1.5-dev libxaw7-dev libxrandr-dev libxt-dev libxxf86vm-
dev libzzip-dev

1.1 Install OIS


Go to OIS's download's page: http://sourceforge.net/project/showf...roup_id=149835 and download the latest release.
Decompress the file, open a terminal window, and cd to the decompressed folder. Then, in a rather particular order,
type:
Code:
./bootstrap
./configure
make
sudo make install

1.2 Obtain the OGRE Source


Download the "Ogre x.x.x Source for Linux / OSX" from http://www.ogre3d.org/download/source where x.x.x is the
current distribution number.

1.3 Create a Permanent Location


Unlike most source distributions, you can't simply build, install and dispose. The OGRE directory will need to be
situated in a place you won't mind having it forever. Personally, I have everything in ~/.ogre, but you can choose your
own. If you pick something else, just remember to substitute the location of your permanent folder whenever I say
~/.ogre.

1.4 Unpack and Relocate


Unpack the OGRE source using whatever means you choose, and move it to your undislosed permanent location,
(~/.ogre).
1.5 Configure
Open a terminal window and cd to the OGRE source directory, (~/.ogre/ogre). Now execute the following in the
terminal:
Code:
./bootstrap

Now enter and execute the following:


Code:
./configure

If configuration fails after telling you to get nVidia's Cg library, then see the next step.

1.6 Install nVidia Cg libraries


Note: Do not perform this step if configuration runs successfully.
Download the "Linux x86" (32-bit) or Linux x86-64" (64-bit) tar files from
http://developer.nvidia.com/object/c...html#downloads . Decompress the file to wherever you want, and copy all the
files to their appropriate folders on your system.
After placing the files, you need to reconfigure Ogre:
Code:
./configure

1.7 Make
Once configuration has finished, run the following:
Code:
make

Note that this can take a REALLY long time. On my dual core 2Ghz it took nearly an hour. If you want to speed this
up, you can run make in multithreaded mode using the following command:
Code:
make -j x

where x is twice the number of cores your computer has.


WARNING: Do not execute 'make -j', this will run make with an unlimited number of concurrent threads and will
overload and freeze your OS within a couple seconds. This is called a makebomb.

1.8 Install
Now that everything has (hopefully) been built correctly, you're finally ready to install OGRE. Cross your fingers and
type:
Code:
sudo make install

1.9 Update Dynamic Linker


Now that you've installed everything in its proper place, you need to tell the linker to update it's chaches. Run:
Code:
sudo ldconfig

2 Installing CEGUI [OPTIONAL]

2.0 Install Dependencies


Open a terminal window and type:
Code:
sudo apt-get install libpcre++-dev libpng12-dev libjpeg62-dev libmng-dev libwxgtk2.8-dev

Again, if you're curious, here're the dependencies:


CEGUI: libpcre++-dev
SILLY: libpng12-dev libjpeg62-dev libmng-dev
Layout Editor: libwxgtk2.8-dev
Imageset Editor:

2.1 Download and Relocate


Download the current source release of CEGUI, SILLY Image Loading Library, CEGUI Layout Editor, and CEGUI
Imageset Editor. Unzip all the packages and move CEGUI-x.x.x, CEImagesetEditor-x.x.x and CELayoutEditor-x.x.x
to your permanent location, (~/.ogre).

2.2 Install SILLY


Open a terminal window and cd to the SILLY directory. No execute the following commands, one after another.
Code:
./configure
make
sudo make install

You are now free to dispose of the SILLY source directory.

2.3 Install CEGUI


Now cd to the CEGUI directory, (~/.ogre/CEGUI-x.x.x) and run the following commands:
Code:
./bootstrap
./configure
make
sudo make install
sudo ldconfig

This build also takes a while, so if you want to use multithreading you can replace 'make' with 'make -j x' like last
time.

2.4 Install CEGUI Layout Editor


Open a terminal window, cd to the CEGUI Layout Editor directory, (~/.ogre/CELayoutEditor-x.x.x), and enter:
Code:
./configure
make
sudo make install

To run CEGUI Layout Editor, use 'CELayoutEditor'. You can make a launcher for it or add it to your main menu at
your leisure.
The first time you start it, CELE requires you to give it the location of the default datafiles.

2.5 Install CEGUI Imageset Editor


To be done...

3 Installing QuickGUI [OPTIONAL]

3.0 Install Dependencies


Open a terminal window and type:
Code:
sudo apt-get install cmake

This is pretty self explanatory and is only for building the library. QuickGUI's only other dependency is Ogre.

3.1 Download and Relocate


Obtain QuickGUI from the latest release thread here: http://www.ogre3d.org/addonforums/viewforum.php?f=13 .
Extract the source and move it to your Ogre folder, (~/.ogre).

3.2 Configure
You may either use Code::Blocks or CMake to build the QuickGUI library. If you are using Code::Blocks, the process
is rather self-explanatory.
Note: Code::Blocks only builds the library, but does not install it. You will have to manually move the dynamic
library file (~/.ogre/QuickGUI/bin/libQuickGUI.so) to /usr/local/lib or wherever else you want to put it.
If, however, you decided to use CMake, cd to the QuickGUI source directory, (~/.ogre/QuickGUI) and type:
Code:
cmake .

Note: if you want to alter the default build options, you can type 'ccmake .' rather than 'cmake .'

3.3 Build and Install


Now that CMake has generated the Makefiles for you, you can simply run:
Code:
make
sudo make install
sudo ldconfig
4 Installing Bullet

4.0 Install Dependencies


Use apt-get to install dependencies:
Code:
sudo apt-get install freeglut3-dev

4.1 Obtain Source


Download the Bullet source code from here: http://code.google.com/p/bullet/downloads/list . You don't need to keep
the Bullet source, so feel free to install it right from your desktop.

4.2 Make
Open a terminal to the Bullet source directory and type:
Code:
./autogen.sh
./configure
make -j 4

4.3 Install
As of the time of this writing, the install-sh script included with Bullet has incompatible line endings. Download
another version from here: http://www.fastcgi.com/devkit/install-sh and replace the one in the Bullet folder. Then you
can run:
Code:
sudo make install
sudo ldconfig

5 Creating an OGRE Project


Note: I will be using Code::Blocks for these instructions, although they will probably be easily adaptable to other
IDEs as well.

5.1 Create an Empty project


Open Code::Blocks and select File->New->Project. Choose an Empty Project, (the Ogre Project is broken on Linux),
click Go, and choose a location. Leave all the options on the next page default and click Finish.

5.2 Add Linked Libraries


In Project->Build Options select the "Linker Settings" tab and add "OgreMain" and "GL" to the "Link Libraries" box.
Note: Also add "OIS" for OIS, "CEGUI" for CEGUI, "QuickGUI" for QuickGUI depending on which of these
additional libraries you will be using. If you are using Bullet, it is absolutely essential that you include "bulletmath",
"bulletcollision", and "bulletdynamics" in exactly that order.

5.3 Setting up your plugins.cfg File


Create a file named "plugins.cfg" in the directory your project's executable will reside in. At the very minimum, this
should include the following:
Code:
PluginFolder=/usr/local/lib/OGRE
Plugin=RenderSystem_GL.so
Plugin=Plugin_OctreeSceneManager.so

5.4 Using the Example Application [OPTIONAL]


If you are doing the tutorials or otherwise basing your project on the Example Application framework included with
the OGRE source, you must copy the Samples/Media, and the Samples/Common/include/* from your OGRE source
directory, (~/.ogre/ogre), to your project directory and your project include directory respectively. Also remember to
add
Code:
#include "ExampleApplication.h"

to your main OGRE file.

Once you have all this done, you should finally be able to follow the generic instructions on the Wiki. I somebody
finds these instructions helpful. The whole installation process was hellishly time consuming and frustrating for me,
and I hope this makes that slightly better.

-Calder
Re: HowTo: Install and Use OGRE

Hey Calder, it's me again.

I install ogre on another computer running ubuntu 9.04 as well (using your tutorial) but this time I paid more attention
to the config summary that ./configure spits out. I noticed that CEGUI demos were not going to be built.
Here take a look:

Code:
--------=== Configuration summary ===--------
Target platform : GLX
OpenGL Ogre support : GLX
GUI library to use : Xt
Use double precision arithmetic : no
Support for threading : no
Memory allocator : ned
Use STLport : no
Use FreeType : yes
Use FreeImage : yes
Use DevIL : no
Build OGRE demos : yes
Build CEGUI demos : false
Build the OpenEXR plugin : no
Build the Cg plugin : yes
Build the DirectX 9 plugin : no
--------===============================--------

So I decided to fix that. Below, I describe the steps I took to have those demos working.

Basically you need to build DEVIL and CEGUI from source. You can get the latest tarballs from here and here
respectively

Before you compile make sure you uninstall the following packages
libdevilc2
libdevil-dev

Now, because I wanted to make sure I had all the dependencies before trying to compile both projects I checked out
the packages suggested at this wiki and compared them with the ones you suggested. Turns out there are some
packages that are not repeated but I don't know how much difference they make. At least i tried them and they didn't
broke anything

Code:
sudo apt-get install pkg-config automake checkinstall libpcre3-dev ibopenexr-dev freeglut-dev
mesa-common-dev libtiff4-dev libglademm-2.4-dev libcppunit-dev libxaw7-dev

These are some I tried on my own but I'm still not really sure if they make a difference or not. Try without them first
Code:
pkg-config freetype2-demos zziplib-bin libmng-dev libtiff-doc libmetacity-dev

Then go to Synaptic and make sure you have all of the following installed (as this will enable sdl support in devil)
libsdl-1.2debian
libsdl-1.2debian-alsa
libsdl-1.2dev
libsdl-image1.2
libsdl-image1.2-dev
libsdl-mixer1.2
libsdl-mixer1.2-dev
libsdl-net1.2
libsdl-net1.2-dev

once you are in the directory where you unpacked the DEVIL source

Code:
autoreconf -i
./configure --enable-ILU --enable-ILUT --with-examples
make
sudo make install
ldconfigq

This should take care of DEVIL. Now to install CEGUI go to the CEGUI where you unpacked the source and type

Code:
aclocal && ./bootstrap && ./configure --with-default-xml-parser=TinyXMLParser
make

If make doesn't complete successfully because a strange compilation error related to ILVoid try the following fix:

in CEGUI-0.6.2/ImageCodecModules/DevILImageCodec/CEGUIDevILImageCodec.cpp
replace all instances of ILvoid with void (I found two)

after that

Code:
sudo make install

This should take care of CEGUI

finally install ogre (again type the following in the dir where you unpacked the ogre tarball)

Code:
aclocal
./bootstrap
./configure
make
sudo make install
sudo ldconfig

After the ./configure you should have CEGUI demos enabled.

Code:
--------=== Configuration summary ===--------
Target platform : GLX
OpenGL Ogre support : GLX
GUI library to use : Xt
Use double precision arithmetic : no
Support for threading : no
Memory allocator : ned
Use STLport : no
Use FreeType : yes
Use FreeImage : yes
Use DevIL : no
Build OGRE demos : yes
Build CEGUI demos : true
Build the OpenEXR plugin : no
Build the Cg plugin : yes
Build the DirectX 9 plugin : no
--------===============================--------

However, there is something that still bothers me and that is the line
Use DevIL : no
I don't know how come. I was able to build DEVIL succesfully so I don't know why ogre's autoconfigure tool can't
find DEVIL. For that I'm going to ask for some help here in the forum.

But I can still build ogre successfully and all the demos seem to work fine
Hope this can be helpful to someone out there.

Re: HowTo: Install and Use OGRE

I am trying to install ogre on ubuntu 9.04


I followed your tutorial but I am getting the following error
thanks for your help in advance

gaurav@gaurav-desktop:~/ogre$ make
Making all in OgreMain
make[1]: Entering directory `/home/gaurav/ogre/OgreMain'
Making all in src
make[2]: Entering directory `/home/gaurav/ogre/OgreMain/src'
/bin/bash ../../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -
I../../OgreMain/include -I/usr/include/freetype2 -I../../OgreMain/include -
DOGRE_NONCLIENT_BUILD -DOGRE_GUI_GLX -fvisibility=hidden -fvisibility-
inlines-hidden -DOGRE_GCC_VISIBILITY -I../../OgreMain/src/nedmalloc -g -O2 -MT
OgreBillboardParticleRenderer.lo -MD -MP -MF
.deps/OgreBillboardParticleRenderer.Tpo -c -o OgreBillboardParticleRenderer.lo
OgreBillboardParticleRenderer.cpp
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../../OgreMain/include -
I/usr/include/freetype2 -I../../OgreMain/include -DOGRE_NONCLIENT_BUILD -
DOGRE_GUI_GLX -fvisibility=hidden -fvisibility-inlines-hidden -
DOGRE_GCC_VISIBILITY -I../../OgreMain/src/nedmalloc -g -O2 -MT
OgreBillboardParticleRenderer.lo -MD -MP -MF
.deps/OgreBillboardParticleRenderer.Tpo -c OgreBillboardParticleRenderer.cpp -fPIC -
DPIC -o .libs/OgreBillboardParticleRenderer.o
OgreBillboardParticleRenderer.cpp:489: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.3/README.Bugs> for instructions.
make[2]: *** [OgreBillboardParticleRenderer.lo] Error 1
make[2]: Leaving directory `/home/gaurav/ogre/OgreMain/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/gaurav/ogre/OgreMain'
make: *** [all-recursive] Error 1

Re: HowTo: Install and Use OGRE

I followed you advice on Ubuntu 9.04 but I am getting the error on make.If you can help..
thanks for your help in advance
--------=== Configuration summary ===--------
Target platform : GLX
OpenGL Ogre support : GLX
GUI library to use : Xt
Use double precision arithmetic : no
Support for threading : no
Memory allocator : ned
Use STLport : no
Use FreeType : yes
Use FreeImage : yes
Use DevIL : no
Build OGRE demos : yes
Build CEGUI demos : false
Build the OpenEXR plugin : no
Build the Cg plugin : yes
Build the DirectX 9 plugin : no
--------===============================--------
make result:-
OgreBillboardParticleRenderer.cpp:489: internal compiler error: in verify_marks_clear, at dwarf2out.c:14909
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.3/README.Bugs> for instructions.
make[2]: *** [OgreBillboardParticleRenderer.lo] Error 1
make[2]: Leaving directory `/home/gaurav/ogre/OgreMain/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/gaurav/ogre/OgreMain'
make: *** [all-recursive] Error 1
Ogre Source Install on Ubuntu 9.04
by admin on Friday, October 2nd 2009 Comments Off
in Uncategorized

I wanted to briefly show how I was able to successfully compile and install the latest v1-6 ogre. All libraries
were compiled on a cleanly installed version of Ubuntu x86_64. These steps worked for me; however it is
possible you will run into conflicts with other pre-installed libraries. I assume you have used subversion
before; if not simply enter:

sudo apt-get install subversion

To acquire the latest of Ogre Shoggoth v1-6:

svn co https://svn.ogre3d.org/svnroot/ogre/branches/v1-6 ogre

Before compiling we will install CEGUI.

sudo apt-get install libcegui-mk2-1 libcegui-mk2-1-dbg libcegui-mk2-dev libcegui-mk2-doc

One more library before compiling Ogre! Get the latest version of OIS here:

http://sourceforge.net/projects/wgois/

Now open up the OIS tar file and run these commands within ois:

./bootstrap && ./configure


sudo make && make install
sudo ldconfig

OK! Compile OGRE:


the subversion download made a ogre folder, cd into it and run these commands:

sudo ./bootstrap && ./configure


sudo make && make install
sudo ldconfig

Are we there yet? NO! There are some very important tasks that must be done for your new Ogre
environment. View the OGRE Samples here first to ensure Ogre is running correctly then continue on:

ogre/Samples/Common/bin
One of the more confusing setup items about OGRE is getting the libraries and headers to talk with your IDE
and even with your linked libraries. Try one or both of these tasks. First verify RenderSystem_GL.so can be
seen:

locate RenderSystem_GL.so

Nothing right? If your library shows RenderSystem_GL.so at /usr/local/lib/OGRE then you have one up on
me. However, I was not able to properly link these libraries even after adding /usr/local/lib to my
/etc/ld.so.conf. If you have a better solution please comment below and correct me. For the time being this
worked for me. My ld.so.conf looks like this:

include /etc/ld.so.conf.d/*.conf
include /usr/local/lib
include /usr/local/lib/OGRE

This did not in fact assist me with an error claiming RenderSystem_GL.so can not be found. Here is my
workaround until I am corrected by someone more educated than myself. I have added this to my home
directory .bashrc:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/OGRE

I hope this will work for you after running:

sudo ldconfig
Make sure to close and open a new terminal window after editing the .bashrc so it sees the newly linked
libraries.

CodeBlocks IDE and config files

Ok to simplify matters I will add pictures to demonstrate my CodeBlocks IDE setup for OGRE. First start a
new EMPTY FILE project for C++. Add the code from OGRE Tutorial 1 to your main.cpp file on your new
project of whatever you named it, don’t name your project ExampleApplication or you will go down another
circular rabbit hole:

#include "ExampleApplication.h"

class TutorialApplication : public ExampleApplication


{
protected:
public:
TutorialApplication()
{
}

~TutorialApplication()
{
}
protected:
void createScene(void)
{
}
};

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32


#define WIN32_LEAN_AND_MEAN
#include “windows.h”

INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )


#else
int main(int argc, char **argv)
#endif
{
// Create application object
TutorialApplication app;

try {
app.go();
} catch( Exception& e ) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBox( NULL, e.what(), “An exception has occurred!”, MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
fprintf(stderr, “An exception has occurred: %s\n”,
e.what());
#endif
}

return 0;
}

Don’t compile just yet, lets add your needed headers and libraries. Go to Projects >> Build Options from the
tool-bar above. Select linker setting and add the following libraries.

/usr/local/lib/libOIS.so
/usr/local/lib/libOgreMain.so
I have also added libraries to the bullet physics engine (ignore the additional libraries shown unless of course
you have installed bullet and would like to use bullet physics), only libOIS and libOgreMain is needed.

Ogre, OIS, and Bullet Physics lib on codeBlocks

This may be optional but I have added these file paths to Search Directories:
OK, so your IDE is setup and OGRE, OIS, CEGUI (Possibly Bullet) are all installed and linked. That means
you can cleanly compile code now. However you cannot execute the code without OGRE knowing where to
look for its MESH files and plugins.

Now lets tell OGRE where all its files are for your new Project. Look inside of the ogre source code you
downloaded with subversion:

ogre/Samples/Common/bin/Debug/

You should see:

Plugins.cfg, resources.cfg, quake3settings.cfg, and media.cfg

Copy all of these config files into your CodeBlocks Debug Project. For example my new project “TEST”, is
located at :

TEST/bin/Debug

So it will be whatever you named your CodeBlocks Project /bin/Debug/plugins.cfg and


/bin/Debug/resources.cfg.

MAKE SURE you rename Plugins.cfg to lowercase plugins.cfg or it will not be read!

Now lets edit your resources.cfg file to point to the Media directory originally found here:
ogre/Samples/Media

The Media folder can remain where it is but I would advise using a copy of it so you can add content of your
own without running the risk of corrupting the pure copy of it. It is entirely up to you. You must edit the
resource.cfg file so that it may locate the Media folder, here is an example:

FileSystem=/home/MyHomedirectory/OGRE/Media

Here is what my resource.cfg looks like, yours WILL be different of course but this should give you a good
idea of what to edit:

Now go into directory:

/usr/local/lib/OGRE

You should see all your Plugin Files for OGRE.

Lets let plugins.cfg know where to find your plugins:


PluginFolder=/usr/local/lib/OGRE

For example:

Now for CodeBlocks Reasons copy both plugins.cfg and resources.cfg to the root folder of your project so
the IDE can execute your code. Otherwise it may be executed already with the terminal with the /bin/Debug
folder:
OK, you should be ready to compile and execute your code without issues. Keep in mind not all your plugins
may make the cut without additional libraries installed. Just comment out the non-working plugins with # for
right now. you don’t need them all just yet anyway.

Now begin learning with the great tutorial here:

http://www.ogre3d.org/wiki/index.php/Ogre_Tutorials

Please let me know if you have any corrective information. I am new to OGRE and do not pretend to be an
expert. I hope this was helpful.

· TrentonKnight

You might also like