Skip to main content

History: Setting Up An Application - Visual Studio

Source of version: 101

Copy to clipboard
            {DIV(class="Layout_box6")}{SPLIT(colsize=15%|85%)}{img fileId="1721"}---
{DIV(class="bigBold")}Setting Up An Application With Visual Studio{DIV}{SPLIT}
{DIV}
%clear%
!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 [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}

{VERSIONS(nav="y",default="Visual Studio 2010 - VC10")}
Guide for setting up an Ogre application using Visual Studio 2010 (VC10).
!!Prerequisites
*Visual Studio 2010 must be installed. Express and higher.
*The Ogre SDK version 1.7 or greater must be installed.
**Installing the Ogre SDK:  ((Installing the Ogre SDK))
**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.
!Setting Up an Application for Visual Studio 2010
!!Environment Variables
Run {MONO()}setx OGRE_HOME path_to_ogre_sdk{MONO} in a command console (cmd.exe):
{img fileId="1655"}
Alternatively, create this handy batch script:
{CODE(wrap="1", colors="winbatch")}
setx OGRE_HOME %CD%
pause
{CODE}
Save it as {MONO()}OGRE_HOME.bat{MONO} and put it in the root directory of the Ogre SDK.
Run it, and the OGRE_HOME environment variable points to that directory.
Handy when you switch between several Ogre SDKs.
!!New Project
Create a new Win32 project ({MONO()}File -> New -> Project{MONO}):
{img fileId="1656" width="400" thumb="y" alt="vc10step1.png" rel="box[g]"}
Make sure that {MONO()}Windows Application{MONO} is selected and {MONO()}Empty Project{MONO} is checked:
{img fileId="1658" width="400" thumb="y" alt="" rel="box[g]"}
!!Tutorial Framework
Tutorial Framework:
{img fileId="1657" width="400" thumb="y" alt="" rel="box[g]"}
Download the ((Ogre Wiki Tutorial Framework)) here:
{ATTACH(id="60", page="Ogre Wiki Tutorial Framework",icon="1")}{ATTACH}
Extract Tutorial Framework:
{img fileId="1659" width="400" thumb="y" alt="" rel="box[g]"}
Add Existing Items to Project:
{img fileId="1660" width="400" thumb="y" alt="" rel="box[g]"}
Select Files:
{img fileId="1661" width="400" thumb="y" alt="" rel="box[g]"}
!!Project Configuration
Project Properties:
{img fileId="1662"}
---
!!!Common Settings
Switching to All Configurations:
{img fileId="1663" width="400" thumb="y" alt="" rel="box[g]"}
---
!!!!General Configuration Properties
Set {MONO()}Character Set{MONO} to {MONO()}''Use Multi-Byte Character Set''{MONO} on the General Configuration Properties page:

{img fileId="1665" width="400" thumb="y" alt="" rel="box[g]"}
---
!!!!Debugging Configuration Properties
{MONO()}Command{MONO}:
{CODE(wrap="1")}
$(OGRE_HOME)\Bin\$(Configuration)\$(ProjectName).exe
{CODE}
{MONO()}Working Directory{MONO}:
{CODE(wrap="1")}
$(OGRE_HOME)\Bin\$(Configuration)
{CODE}

{img fileId="1664" width="400" thumb="y" alt="" rel="box[g]"}
---

!!!!Configuration Properties - C/C++ - General - Additional Include Directories

{CODE(wrap="1")}
$(OGRE_HOME)\include\OIS
$(OGRE_HOME)\include\OGRE
$(OGRE_HOME)\Samples\Common\include
$(OGRE_HOME)\boost_1_42
{CODE}

{img fileId="1667" width="400" thumb="y" alt="" rel="box[g]"}
---
!!!!Configuration Properties - Linker - General - Additional Library Directories
{CODE(wrap="1")}
$(OGRE_HOME)\lib\$(Configuration)
$(OGRE_HOME)\boost_1_42\lib
{CODE}

{img fileId="1668" width="400" thumb="y" alt="" rel="box[g]"}
---
!!!!Configuration Properties - Build Events - Post-Build Event - Command Line

{CODE(wrap="1")}copy "$(OutDir)\$(TargetFileName)" "$(OGRE_HOME)\Bin\$(Configuration)"{CODE}

{img fileId="1669" width="400" thumb="y" alt="" rel="box[g]"}
---
!!!Configuration Specific Settings
{img fileId="1670" width="400" thumb="y" alt="" rel="box[g]"}
---
!!!!Configuration Properties - Linker - Input - Additional Dependencies - Debug
Add input libraries for debug:
{CODE(wrap=1)}
OgreMain_d.lib
OIS_d.lib
{CODE}

{img fileId="1671"}
---
!!!!Configuration Properties - Linker - Input - Additional Dependencies - Release
Add input libraries for release:
{CODE(wrap=1)}
OgreMain.lib
OIS.lib
{CODE}

{img fileId="1672" width="400" thumb="y" alt="" rel="box[g]"}
---
!!That's it!
You've setup an Ogre project succesfully.
All that remains is to build and run it. :)
{img fileId="1673" width="400" thumb="y" alt="" rel="box[g]"}
---(Visual Studio 2008 - VC9)---
!Prerequisites
*Visual Studio 2008 must be installed. [http://www.microsoft.com/express/Downloads/#2008-Visual-CPP|Visual Studio Downloads]
*The Ogre SDK version 1.7 or greater must be installed.
**Installing the Ogre SDK:  ((Installing the Ogre SDK))
**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.
{img fileId="1640" rel="box[g]"}
{DIV(type="span")}{DIV}
*Click the __OK__ button and the Win32 Application Wizard will be displayed.
{DIV(type="span")}{DIV}
{img fileId="1642" rel="box[g]"}
{DIV(type="span")}{DIV}
*Click the __Next__ Button.
*Select 'Windows Application' and 'Empty project' when prompted for the type of project to create.
{DIV(type="span")}{DIV}
{img fileId="1643" rel="box[g]"}
{DIV(type="span")}{DIV}
*Click the __Finish__ button.
{DIV(type="span")}{DIV}
!!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 to download the zip file.--
{DIV(type=span, bg="yellow")}Get the ((Ogre Wiki Tutorial Framework)) instead!{DIV}
*Extract the files into your project folder. 
{DIV(type="span")}{DIV}
{img fileId="1644" rel="box[g]"}
{DIV(type="span")}{DIV} 
*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.
{DIV(type="span")}{DIV}
{img fileId="1648" rel="box[g]"}
{DIV(type="span")}{DIV}
*Open each of the folders by clicking on the __+__ signs to the left of each folders name.
{DIV(type="span")}{DIV}
{img fileId="1649" rel="box[g]"}
{DIV(type="span")}{DIV}
*Right click on the each of the files and select __Include In Project__.
{DIV(type="span")}{DIV}
{img fileId="1650" rel="box[g]"}
{DIV(type="span")}{DIV}
*Select File|Save All from the Visual Studio menu.
!!Setting up the environment
{REMARKSBOX(type="tip",highlight="y")}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{REMARKSBOX}

*Right click on the project OgreTemplate and select properties.  The following screen will be displayed.
{DIV(type="span")}{DIV}
{img fileId="1651" rel="box[g]"} 
{DIV(type="span")}{DIV}

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.
{DIV(type="span")}{DIV}
{CODE()}
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)
{CODE}
{DIV(type="span")}{DIV}
*Select the __Debug__ Configuration by selecting the Configuration drop-down box and selecting "Debug".  Set the properties according to the following chart.
{DIV(type="span")}{DIV}
{CODE()}
Linker | Input | Additional Dependencies            : OgreMain_d.lib OIS_d.lib
Linker | Debugging | Generate Debug Info            : Yes (/DEBUG)
{CODE}
{DIV(type="span")}{DIV}
*Select the __Release__ Configuration by selecting the Configuration drop-down box and selecting "Release".  Set the properties according to the following chart.
{DIV(type="span")}{DIV}
{CODE()}
Linker | Input | Additional Dependencies : OgreMain.lib OIS.lib
Linker | Debugging | Generate Debug Info : No
{CODE}
!!Building the project
{DIV(type="span")}{DIV}
*Choose the __Debug__ Solution Configuration.
*Right click on the project OgreTemplate and select __Build Project__.
There should be no compile or link errors.
{DIV(type="span")}{DIV}
{img fileId="1652" rel="box[g]"} 
{DIV(type="span")}{DIV}
*Choose the __Release__ Solution Configuration.
*Right click on the project OgreTemplate and select __Build Project__.
There should be no compile or link errors.
{DIV(type="span")}{DIV}
{img fileId="1653" rel="box[g]"}
{DIV(type="span")}{DIV}

!!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.  
---(Visual Studio 2005 - VC8)---
TBD
---(Visual Studio 2003 - VC7.1)---
TBD
{VERSIONS}

        

History

Information Version
Wed 22 of Apr, 2020 09:56 GMT-0000 paroj 141
Mon 24 of Aug, 2015 04:11 GMT-0000 petrocket Fixed link to Ogre app wizard 140
Sun 31 of May, 2015 11:26 GMT-0000 spacegaier 139
Tue 31 of Mar, 2015 06:24 GMT-0000 kabbotta 138
Fri 17 of Oct, 2014 13:29 GMT-0000 spacegaier 137
Fri 19 of Sep, 2014 08:50 GMT-0000 gerymate 136
Fri 19 of Sep, 2014 08:49 GMT-0000 gerymate 135
Sat 21 of Sep, 2013 21:04 GMT-0000 Flateno Page updated for alternative Ogre 1.9 134
Sat 21 of Sep, 2013 20:57 GMT-0000 Flateno 133
Sat 21 of Sep, 2013 20:55 GMT-0000 Flateno 132
Sat 21 of Sep, 2013 20:42 GMT-0000 Flateno Update for Ogre 1.9 131
Sat 21 of Sep, 2013 20:27 GMT-0000 Flateno 130
Sat 21 of Sep, 2013 20:27 GMT-0000 Flateno 129
Sat 21 of Sep, 2013 19:49 GMT-0000 Flateno 128
Sat 21 of Sep, 2013 19:48 GMT-0000 Flateno 127
Sat 21 of Sep, 2013 19:48 GMT-0000 Flateno 126
Sat 21 of Sep, 2013 19:38 GMT-0000 Flateno 125
Sat 21 of Sep, 2013 19:35 GMT-0000 Flateno 124
Sat 21 of Sep, 2013 19:30 GMT-0000 Flateno 123
Fri 08 of Jun, 2012 03:47 GMT-0000 jacmoe 122
Fri 25 of May, 2012 23:55 GMT-0000 jacmoe Boost version is no longer part of directory name 121
Mon 26 of Mar, 2012 07:42 GMT-0000 Nikitron 120
Mon 26 of Mar, 2012 07:41 GMT-0000 Nikitron Fixed links to new version of the Boost from the Ogre. 119
Fri 14 of Oct, 2011 08:25 GMT-0000 Tytanis Added ogre.cfg because I believe it should be here as well! 118
Sun 31 of Jul, 2011 23:41 GMT-0000 jacmoe 117