OGRE Wiki
Support and community documentation for Ogre3D
Ogre Forums
ogre3d.org
Log in
Username:
Password:
CapsLock is on.
Remember me (for 1 year)
Log in
Home
Tutorials
Tutorials Home
Basic Tutorials
Intermediate Tutorials
Mad Marx Tutorials
In Depth Tutorials
Older Tutorials
External Tutorials
Cookbook
Cookbook Home
CodeBank
Snippets
Experiences
Ogre Articles
Libraries
Libraries Home
Alternative Languages
Assembling A Toolset
Development Tools
OGRE Libraries
List of Libraries
Tools
Tools Home
DCC Tools
DCC Tutorials
DCC Articles
DCC Resources
Assembling a production pipeline
Development
Development Home
Roadmap
Building Ogre
Installing the Ogre SDK
Setting Up An Application
Ogre Wiki Tutorial Framework
Frequently Asked Questions
Google Summer Of Code
Help Requested
Ogre Core Articles
Community
Community Home
Projects Using Ogre
Recommended Reading
Contractors
Wiki
Immediate Wiki Tasklist
Wiki Ideas
Wiki Guidelines
Article Writing Guidelines
Wiki Styles
Wiki Page Tracker
Ogre Wiki Help
Ogre Wiki Help Overview
Help - Basic Syntax
Help - Images
Help - Pages and Structures
Help - Wiki Plugins
Toolbox
Freetags
Categories
List Pages
Structures
Trackers
Statistics
Rankings
List Galleries
Ogre Lexicon
Comments
History: Setting Up An Application - Linux - Shoggoth
View page
Source of version: 1
(current)
%prevogre% {maketoc} !!Autotools To build your application using the ubiquitous GNU [http://sources.redhat.com/autobook/autobook/autobook_toc.html|autotools] (autoconf + automake + libtool), create these files in your project folder with the following content: {DL()} bootstrap:: {DL} {CODE(wrap="1")} #!/bin/sh rm -rf autom4te.cache libtoolize --force --copy && aclocal && autoheader && automake --add-missing --force-missing --copy --foreign && autoconf {CODE} {DL()} configure.ac:: {DL} {CODE(wrap="1")} 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 {CODE} {DL()} Makefile.am:: {DL} {CODE(wrap="1")} SUBDIRS = include src EXTRA_DIST = bootstrap AUTOMAKE_OPTIONS = foreign {CODE} {DL()} include/Makefile.am:: {DL} {CODE(wrap="1")} noinst_HEADERS= SampleApp.h {CODE} {DL()} src/Makefile.am:: {DL} {CODE(wrap="1")} 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) {CODE} {ALINK(aname="Your First Application")}Your First Application{ALINK} or ((MinimalApplication|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|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: {CODE(wrap="1")} scons {CODE} 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: {CODE(wrap="1")} 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='.') {CODE} 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: {CODE(wrap="1")} include bin/windows/debug bin/windows/release bin/linux/debug bin/linux/release {CODE} * In linux, write any of the following lines in the command line: {CODE(wrap="1")} 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 {CODE} In windows, use the following lines: * For debug build: {CODE(wrap="1")} scons MSTOOLKIT=yes OS=windows mode=debug {CODE} * For release build: {CODE(wrap="1")} scons MSTOOLKIT=yes OS=windows {CODE} * For debug clean: {CODE(wrap="1")} scons MSTOOLKIT=yes OS=windows mode=debug -c {CODE} * For release clean: {CODE(wrap="1")} scons MSTOOLKIT=yes OS=windows -c {CODE} !!!Alternate Scons File Please actually read this file, it's easy to understand and __will__ require some modification for use. {CODE(wrap="1")} # A Linux Ogre/CEGUI/OIS/OgreOde build Script by [[User:Grey|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']) {CODE} !!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] # Create a new Generic/Terminal App project. # Choose c++ and Executable target when prompted. # Delete all of the included template code in main.cc. It will be replaced with the sample code below. # Go to the Settings Menu and choose Compilier and Linker Settings. # 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. {DL()} Include Paths: {DL} {CODE(wrap="1")} $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 {CODE} {DL()} Library paths: {DL} {CODE(wrap="1")} /usr/local/lib {CODE} {DL()} Libraries: {DL} {CODE(wrap="1")} OgreMain CEGUIBase CEGUIOgreRenderer OIS{CODE} {DL()} Options {DL} {CODE(wrap="1")} check "Enable Debugging" (adds -g to the command line) {CODE} {DL()} Options | Compilier flags (CFLAGS): {DL} {CODE(wrap="1")} -DEXT_HASH {CODE} !!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. {CODE(wrap="1")} PKG_CHECK_MODULES(OGRE, [OGRE >= 1.2.0]) {CODE} * Open "src/Makefile.am" and add the following lines. {CODE(wrap="1")} LDADD = @OGRE_LIBS@ AM_CXXFLAGS = @OGRE_CFLAGS@ {CODE} * To avoid linker errors, add these lines to src/Makefile.am {CODE(wrap="1")} sampleapp_LDADD = /usr/local/lib/libOIS.so /usr/local/lib/libOgreMain.so{CODE} * 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 ((Cross Compiling OGRE on Linux)) ((Cross-Compiling OGRE on Debian)) See also: [http://www.ogre3d.org/wiki/index.php/Cross_Compiling_in_Linux|How to compile applications for MS Windows platform from within Linux] --- {INCLUDE(page="Setting Up An Application - First Application")}{INCLUDE}
Search by Tags
Search Wiki by Freetags
Latest Changes
IDE Eclipse
FMOD SoundManager
HDRlib
Building Ogre V2 with CMake
Ogre 2.1 FAQ
Minimal Ogre Collision
Artifex Terra
OpenMB
Advanced Mogre Framework
MogreSocks
...more
Search
Find
Advanced
Search Help
Online Users
82 online users