History: Setting Up An Application - Visual Studio
Preview of version: 76
- «
- »
Table of contents
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.
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: No SDK install yet
- 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 setx OGRE_HOME path_to_ogre_sdk in a command console (cmd.exe):
Alternatively, create this handy batch script:
setx OGRE_HOME %CD% pause
Save it as OGRE_HOME.bat 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 (File -> New -> Project):
Make sure that Windows Application is selected and Empty Project is checked:
Tutorial Framework
Tutorial Framework:
Get the framework from Ogre Wiki Tutorial Framework
Extract Tutorial Framework:
Add Existing Items to Project:
Select Files:
Project Configuration
Common Settings
Switching to All Configurations:
General Configuration Properties:
Debugging Configuration Properties:
VC++ Directories:
Configuration Properties - C/C++ - General - Additional Include Directories:
Configuration Properties - Linker - General - Additional Library Directories:
Configuration Properties - Build Events - Post-Build Event - Command Line:
Configuration Specific Settings
Configuration Properties - Linker - Input - Additional Dependencies:
Add input libraries for debug:
Add input libraries for release:
That's it!
You've setup an Ogre project succesfully.
All that remains is to build and run it. 😊
-(Visual Studio 2008 - VC9)-
Prerequisites
- Visual Studio 2008 must be installed. Visual Studio Downloads
- The Ogre SDK version 1.7 or greater must be installed.
- Installing the Ogre SDK: No SDK install yet
- 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 No such attachment on this page 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
- 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.
-(Visual Studio 2005 - VC8)-
TBD
-(Visual Studio 2003 - VC7.1)-
TBD