History: Setting Up An Application - CodeBlocks
Source of version: 59
Copy to clipboard
{DIV(class="Layout_box1")}{SPLIT(colsize=15%|85%)}{IMG(src="img/wiki_up/CBsplash.jpg")}{IMG}---
{DIV(class="bigBold")}Setting Up An Application With Code::Blocks And MinGW{DIV}{SPLIT}
{DIV}
%clear%
!Introduction
This set of instructions will walk you through setting up a Code::Blocks C++ project from scratch. An alternative to this tutorial is to use the [http://code.google.com/p/ogreappwizards/|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)).
{maketoc}
!Prerequisites
Install the Ogre SDK as detailed here: ((Installing the Ogre SDK))
%warning% Make sure that the environment variable OGRE_HOME is pointing to the root of the Ogre MinGW SDK.
!Setting up Code::Blocks / MinGW for OGRE Development
!!Install TDM MinGW
You need to grab the latest MinGW GCC from Twilight Dragon Media:
[http://www.tdragon.net/recentgcc/|http://www.tdragon.net/recentgcc/]
At this time of writing, it's tdm-mingw-1.908.0-4.4.1-2, based on GCC 4.4.1.
Run the tdm-mingw installer, leaving all settings at their default.
Check that 'Add to PATH' is checked, as that's important.
!!Install Code::Blocks
Download the Code::Blocks [http://www.codeblocks.org/downloads/binaries|official release].
Create a directory for it - C:\CodeBlocks - and unzip the three archives into it.
Start Code::Blocks and pick the MinGW compiler from the list of detected build systems.
Goto {MONO()}~np~Settings -> Compiler and Debugger~/np~{MONO} to show the Global compiler settings:
{img fileId="1695" width="400" thumb="y" alt="" rel="box[g]"}
It should be populated properly, but it can't hurt to check. (:smile:)
!!Create new Console application project
Click the 'Create a new project' link in the Code::Blocks start page, or find it in the menu.
Choose 'Console application':
{img fileId="1696" width="400" thumb="y" alt="" rel="box[g]"}
Be sure to put the project in a directory with no spaces in the (full) name.
A good name would be 'C:\Projects\OgreProject':
{img fileId="1697" width="400" thumb="y" alt="" rel="box[g]"}
---
!!Add the Wiki Tutorial Framework
Now we need to add some files to the project.
Download the ((Ogre Wiki Tutorial Framework)): {ATTACH(id="54", page="Ogre Wiki Tutorial Framework",icon="1")}{ATTACH}.
Unpack the four files into your new OgreProject directory:
{img fileId="1698" width="400" thumb="y" alt="" rel="box[g]"}
Right-click ''main.cpp'' in the project tree and delete it.
Now, we need to add the wiki tutorial framework to our project.
Right-click and ''Add files recursively...'':
{img fileId="1699"}
You are given a list of four files. Click 'OK' to add them:
{img fileId="1700" width="400" thumb="y" alt="" rel="box[g]"}
---
!!Project Build Options
Right-click our OgreProject and choose ''Build options'' from the context menu:
{img fileId="1701"}
!!!Common Build Options
!!!!Compiler settings - Other options
Set {MONO()}Compiler settings - Other options{MONO} to
{CODE(wrap="1")}
-mthreads
-fmessage-length=0
-fexceptions
-fident
{CODE}
{img fileId="1702" width="400" thumb="y" alt="" rel="box[g]"}
Make sure that {MONO()}OgreProject{MONO} is selected, and not one of the build configurations.
!!!!Compiler settings - defines
Set {MONO()}Compiler settings - defines{MONO} to
{CODE(wrap="1")}
WIN32
_WINDOWS
{CODE}
{img fileId="1703" width="400" thumb="y" alt="" rel="box[g]"}
Again, make sure that {MONO()}OgreProject{MONO} is selected, and not one of the build configurations.
!!!!Linker settings - Other linker options
Set {MONO()}Linker settings - Other linker options{MONO} to
{CODE(wrap="1")}
-Wl,--enable-auto-image-base
-Wl,--add-stdcall-alias
-Wl,--enable-auto-import
{CODE}
{img fileId="1704" width="400" thumb="y" alt="" rel="box[g]"}
Again, make sure that {MONO()}OgreProject{MONO} is selected in the configuration tree.
!!!!Search Directories - Compiler
Set {MONO()}Search Directories - Compiler{MONO} to
{CODE(wrap="1")}
$(OGRE_HOME)\include
$(OGRE_HOME)\include\OGRE
$(OGRE_HOME)\include\OIS
$(OGRE_HOME)\boost_1_42
{CODE}
{img fileId=1920 width=400 thumb=y rel=box[g]}
It would be prudent to mention that {MONO()}OgreProject{MONO} should be selected in the configuration tree (and not one of the build configurations)
!!!!Search Directories - Linker
Set {MONO()}Search Directories - Linker{MONO} to
{CODE(wrap="1")}
$(OGRE_HOME)\bin\$(TARGET_NAME)
{CODE}
{img fileId="1706" width="400" thumb="y" alt="" rel="box[g]"}
Again, you need to have {MONO()}OgreProject{MONO} selected, not one of the build configurations! (:razz:)
!!!Debug Build options
Select the {MONO()}Debug{MONO} build configuration in the configuration selector on the left.
!!!!Debug - Compiler settings - defines
Set {MONO()}Debug - Compiler settings - defines{MONO} to
{CODE(wrap="1")}
_DEBUG
{CODE}
{img fileId="1707" width="400" thumb="y" alt="" rel="box[g]"}
---
!!!!Debug - Linker settings - Link libraries
Set {MONO()}Debug - Linker settings - Link libraries{MONO} to
{CODE(wrap="1")}
OgreMain_d
OIS_d
{CODE}
{img fileId="1708" width="400" thumb="y" alt="" rel="box[g]"}
---
!!!Release Build options
!!!!Release - Compiler settings - defines
Set {MONO()}Debug - Compiler settings - defines{MONO} to
{CODE(wrap="1")}
NDEBUG
{CODE}
{img fileId="1709" width="400" thumb="y" alt="" rel="box[g]"}
---
!!!!Release - Linker settings - Link libraries
Set {MONO()}Release - Linker settings - Link libraries{MONO} to
{CODE(wrap="1")}
OgreMain
OIS
{CODE}
{img fileId="1710" width="400" thumb="y" alt="" rel="box[g]"}
---
!Conclusion
That's it.
You should now be able to compile and run your Ogre application.
Well, maybe not until you've copied it to the Ogre sdk bin directory.
Or by copying Ogre dlls and media..
But that's something for a later wiki article..
Proceed to the ((Tutorials)). (:smile:)