%prevogre%

MS Visual C++

Prerequisites

Development Environment Specific Dependencies

The Ogre team offers full support for Visual C++ 2008 (all editions including Express).

Tip_icon.png You need to install Service Pack 1 for Visual Studio 2008 - and the ATL security fix as well (available through Microsoft Update).


Dependencies
The precompiled dependencies is available here.
The dependencies work with both the current stable branch (Shoggoth, or 1.6) as well as SVN HEAD (Ogre 1.7 a.k.a. Cthugha).

DirectX SDK

Download the latest DirectX 9.0 SDK from http://msdn.microsoft.com/directx.

The DirectX SDK install should automatically update the Visual Studio include and library paths with the locations of the DX SDK includes and lib paths. If not, you will need to enter the DirectX include and library directories into MSVC so you can compile against the SDK. It would look something like this:

  • Select Tools|Options|Projects|VC++ Directories

Info Path to the folder must be ON TOP of the list or you will get errors during compilation (Example: error LNK2001: unresolved external symbol _IID_IDirect3DBaseTexture9)

  • Under library files, set the appropriate library directory for the SDK. E.g.,

C:\Program Files\Microsoft DirectX SDK (August 2007)\Lib\x86

  • Under include files, set the appropriate include directory for the SDK. E.g.,

C:\Program Files\Microsoft DirectX SDK (August 2007)\Include

Ogre Source

  • Go to http://www.ogre3d.org and select, More Downloads, then Source: Windows. Alternately, you can get the source from SVN, using the instructions at http://www.ogre3d.org/index.php?option=com_content&task=view&id=415&Itemid=144. The current stable branch is titled "+v1"6+".
  • Extract the Ogre source (if you downloaded a source tarball).
  • Regardless of how you obtained the source, you will then need to extract the Dependencies inside the ogre folder (so that you end up with an ogre/Dependencies folder).


If for whatever reason you want to build dependencies yourself (e.g. you're using the unstable version and precompiled dependencies aren't available), see the Building Dependencies page.

Building

With the prerequisites installed, we are ready to build OGRE.

  • Open the ogre\ogre.sln file (ogre\Ogre_vc8.sln for VC++ 2005 and VC++ 2008, all editions; VC++ 2008 will convert the solution and projects for you)
  • Click "build all".


The build process takes around 15 minutes on a modern P4 class system. If all goes well, the engine, plugins, tools, and demos will build.

Next, try running the demos to verify everything worked. They are found in ogre\Samples\Common\bin\Debug (or bin\Release if built in release mode).

Project Setup

If you are using VC++ .NET 2003 or later, you can use the Ogre Application Wizard and you are ready to create OGRE apps. See also The Complete Blanks Guide To Using The OGRE SDK AppWizard - Shoggoth.

If you feel like setting up a project manually, heres how:

Provided with OGRE is a subclassable ExampleApplication class (found in ogre\Samples\Common\include, just for future reference), which will allow you to develop applications very quickly using a fairly standard set of parameters. While OGRE will allow you to build most any kind of application you wish, the ExampleApplication will provide you with a good base for the majority of 3D applications, and is even suitable for building production-level apps off of.

We'll start by setting up a new Visual C++ Win32 project.

Make sure that "Empty Project" is checked in the application settings. I like to create my smaller projects in the ogre\Samples directory, simply for consistency's sake. You can put them wherever you like, however.

Once you have your project, the first thing you're going to want to do is set up your project properties to use OGRE. There is a tutorial on doing this here (http://www.ogre3d.org/wiki/index.php/SettingUpAnApplication). The tutorial will also walk you through the basics of setting up an app, so feel free to browse through it. However, if you just want the quick rundown, here's what you'll need to do:

  • Right-click the project name in the solution explorer and select "Properties".
  • Add the ogre\OgreMain\include and ogre\Samples\Common\include directories to your "additional includes" directory (Found under C++/General). Visual Studio requires you to create a .cpp or .h file for the C++ options to show up.
  • Add ogre\OgreMain\lib\(Debug|Release) to your "library search paths" field (found under Linker/General)
  • Add OgreMain.lib to the "Additional Dependencies" field (found under Linker/Input)


(Note - if you've downloaded the libraries from the Ogre website and are using the Debug ones you will need to make this OgreMain_d.lib — not adding the _d will cause ~4 perplexing linker errors. Hope this helps anyone in need. --lurkingfridge79)

  • Under C++/Code Generation, change "Runtime Library" to "Multi-threaded Debug DLL" (for debug-mode apps) and "Multi-threaded DLL" (For release-mode apps).


It is also recommended that you change your "Output Directory" (under General) and your "Working Directory" (under Debugging) to the ogre\Samples\Common\bin\(Debug|Release) directory. This will place the file in the same directory as the already-existing OGRE DLL and configuration files, which are required for any OGRE-based app to run. If you do not do this, you will need to copy a lot of the OGRE DLL and config files over to your output directory, as well as rework your config files and such to get it working properly. This is NOT recommended for your first shot at this.

Once that's done, we can start to use OGRE. Create a file called main.cpp, and see Setting Up An Application - Shoggoth.


Code Blocks

GCC & Code::Blocks

For Ogre 1.6.0 RC1 the Code::Blocks workspace is not correctly configured. Download the Ogre source from SVN instead. See this thread for additional information.

For Ogre 1.4 follow this link Code::Blocks + MinGW C++ Toolbox.

For Ogre 1.2.2 there is an alternative option of using Code::Blocks + MingW + STLPort

For Ogre 1.0.x with Code::Blocks 1.0RC2

Here are the steps to build Ogre with mandrav's excellent Code::Blocks IDE under Windows.

Performance Tip: It is suggested to disable Code::Blocks code completion plugin, before opening the Ogre workspace. This workspace contains ~40 projects which will be parsed. Since you 'll be building Ogre and not editing it, you won't be needing this parsing step.

Installation steps:

  1. Download the Ogre source distribution for Windows and unzip it. Everything will unpack in the ogre directory.
  2. Download codeblocks-dependencies-x.x.x.zip.
  3. Unzip codeblocks-dependencies-x.x.x.zip inside ogre (this creates the Dependencies directory)
  4. Launch Code::Blocks and open ogre/Ogre.workspace (wait until all projects have loaded)
  5. Hit "Build/Build Workspace"
  6. Sit back for a few minutes (17mins on a Intel P4 3.0G)
  7. Copy ogre/dependencies/bin/*.dll to ogre/samples/common/bin/release


Before being able to run the provided samples, you should comment out (using a hash # in front of it) the line Plugin=RenderSystem_Direct3D7 inside samples/common/bin/release/plugins.cfg.

You will need quake3 data files(.pk3 and .bsp) in order to run the BSP demo. If you have the files but got a ZipArchive::checkZzipError, just edit ogre\Samples\Common\bin\Release\quake3settings.cfg to point at your quake3 pak and bsp files.

You might have a problem building PlatformManager_Win32: The ogre/Ogre.workspace file has a 2 missing paths for the PlatformManager_Win32 build. To fix it, do the following:

  1. Right click on PlatformManager_Win32 in the workspace window on the left.
  2. Select "Build Options"
  3. Select the "Directories" tab and next the "Resource Compiler" tab.
  4. Add the following 2 directores ..\include and ..\misc, but clicking "Add" and the selecting those directories.
  5. Everything should build correctly now.


Enjoy!

MS Visual C++ Toolkit 2003 and Code::Blocks

Unfortunately the Visual C++ Toolkit does not come with necessary libraries for Multithreaded DLL compiling. This means you won't be able to compile Ogre with it, or at least not easily. The recommended solution for windows is to buy MSVC 7.1 or use [[#GCC & Code::Blocks|GCC]] with one of the IDEs available.

Discipline gave it a good shot at this thread in the forums. If you find a solution, please remove this and post it here. Also use the Codeblocks page for reference.

Update: You can get the multi-threaded dll runtime libraries by following the instructions at: http://manageddreams.com/osmpwiki/index.php?title=Notes_on_Microsoft_Visual_CPP_Toolkit_2003


Eclipse

If you want to compile Ogre on Windows without cygwin, pkgconfig, autotools, bootstrap, configure, etc. and use only gcc, then take a look : Building Under Eclipse And GCC

For question/suggestion use the forum thread : Eclipse + Gcc 3.4 (MinGW + Msys) + Ogre 1.0.3 (http://www.ogre3d.org/phpBB2/viewtopic.php?p=90097).

This is work in progress, feedback is appreciated. Help appreciated for a Linux + Mac version.
edit
(K)Ubuntu Linux Notes

  • Here (http://inetserver.europe.homeip.net/~heiko/?p=102) you can see what it takes to compile ogre on Ubuntu Linux.
  • If you run into linker problems with (K)Ubuntu and the aforementioned instructions, try issuing the command export CC=g++ before running ./configure


Setting Up The Anjuta IDE You might want to use an IDE to make your development in Ogre a tad easier. To do so, follow the instructions in this Ogre Forum Thread (http://www.ogre3d.org/phpBB2/viewtopic.php?t=5100), but to paraphrase:

  • Make a new Generic / Terminal
  • After following the prompts, change your Project->Project Options Configuration tab and Libraries sub-tab and add:

PKG_CHECK_MODULES(ogre, [OGRE >= 1.0.0])
AC_SUBST(ogre_CFLAGS)
AC_SUBST(ogre_LIBS)

  • Then go into Settings -> Compiler and linker options and add ${ogre_CFLAGS} to CFLAGS and ${ogre_LIBS} in Linker Flags
  • Finally, go to Build->Autogenerate and it should update your make and config files automatically.


Enjoy Ogre in Linux — bana


Cygwin

Use the following if you don't want to have to setup Code::Blocks, but would like to have just a pure Cygwin/MinGW environment. Cygwin is used for it's building system and since it can nicely cross-compile for MinGW, you will have a build that doesn't depend on Cygwin anymore.

Note: This information is ripped from this thread in the the Ogre forums.

  1. Fully install cygwin. You might need to add the correct path to /etc/profile.
  2. Get OGRE from CVS (there is a tutorial on how to do it in the CVS Access section). I put this on /usr/dev/ogre. This should also work with release version 1.0.0 or later - actually it worked with 1.0.0RC1 (I used the linux/OSX version. Didn't try the win32, but it must be not that different).
  3. Get the MingW/Cygwin OGRE dependencies from the OGRE website. Either extract it to the root (thus creating /mingw) or to another directory and create a symlink /mingw pointing to the correct location. If you want to build the OGRE dependencies yourself read Build OGRE dependencies using MSYS.
  4. Download and install libtool 1.5.12 (or newer). Version 1.5.10 (the one that came with cygwin) generates a few errors we want to avoid.
    1. Download the stable version from the libtool website.
    2. Configure and install it.
    3. Cygwin has a libtool wrapper that automatically selects 1.5.10 or 1.4.3 - we need to make it use our 1.5.12 (or newer) version instead. To do so, we first copy the libtool files from /usr/local/bin to /usr/autotool/1.5.x/bin (you'll have to create it), then edit /usr/bin/libtool to use that directory instead of the devel dir. It's just a quick, nasty hack - if someone knows of a better way to get the same result, please feel free to write your solution in right here. This shouldn't break anything though.
    4. (Optional): Go to a directory without configure.ac or configure.in files and do a 'libtool --version' to see if the first version number changed. If so, we can go to the next step.
  5. Follow the instructions on the beginning of this post, which I modified slightly and reproduce here. This is to be done in the ogre directory:
    1. export PATH="$PATH:/mingw/bin"
    2. export ACLOCAL_FLAGS="-I /mingw/share/aclocal"
    3. export PKG_CONFIG_PATH=/mingw/lib/pkgconfig
    4. ./bootstrap
    5. CC="gcc -mno-cygwin" CXX="g++ -mno-cygwin" CXXFLAGS="-O2 -I/mingw/include" LDFLAGS="-L/mingw/lib -L/lib/w32api" ./configure --with-ft-prefix=/mingw --with-platform=Win32 --with-gl-support=Win32 --disable-static --build="i686-pc-mingw32" --enable-direct3d
    6. make
    7. make install
  6. Set up your development tools.
    1. Passing the arguments "-lOgreMain -Wl,--enable-runtime-pseudo-reloc" to the linker will work.
    2. As far as library directories go, you can link to cygwin/usr/local/lib and be happy about it.
    3. Include directories: cygwin/usr/local/include, cygwin/usr/local/include/OGRE and ogre/Samples/Common/include (if you are using the ExampleApplication class). Where I say cygwin/, I actually mean the cygwin path (such as c:/cygwin) and the same goes for ogre/ (c:/cygwin/usr/local/ogre/ogre, for example).
    4. This is not required, but I tend to copy all required DLLs to my build directory (the one where MingW puts my compiled binary in). By this, I keep my environment clean and you can just copy that directory to another computer and run it with its own dlls. This avoids mess.


There you go. You should be able to safely build any post-1.0.0 with this, unless there are some big changes that break the process.

Additional Notes :

  1. With the last releases of Cygwin, you don't have to compile a new libtool anymore.
  2. I had to tune the makefiles of several Plugins in order to compile: the ld option "-Wl,-z,defs" was refused. I replaced it with its other syntax "-Wl,--no-undefined" everytime I found it and it worked well.


GCC & Dev C++

Note: This is deprecated, and generally not recommended. DevCPP is old, the Ogre devpak is old, and you will have a much better time using Code::Blocks with MingW.


If you really, really want to do this, keep in mind that you are on your very own here. You are not likely to get any support on the OGRE Forum, other than people telling you to try other options.

You have been warned: Building From Source using DevCPP

<HR>
Creative Commons Copyright -- Some rights reserved.


THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.

BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.

1. Definitions

  • "Collective Work" means a work, such as a periodical issue, anthology or encyclopedia, in which the Work in its entirety in unmodified form, along with a number of other contributions, constituting separate and independent works in themselves, are assembled into a collective whole. A work that constitutes a Collective Work will not be considered a Derivative Work (as defined below) for the purposes of this License.
  • "Derivative Work" means a work based upon the Work or upon the Work and other pre-existing works, such as a translation, musical arrangement, dramatization, fictionalization, motion picture version, sound recording, art reproduction, abridgment, condensation, or any other form in which the Work may be recast, transformed, or adapted, except that a work that constitutes a Collective Work will not be considered a Derivative Work for the purpose of this License. For the avoidance of doubt, where the Work is a musical composition or sound recording, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered a Derivative Work for the purpose of this License.
  • "Licensor" means the individual or entity that offers the Work under the terms of this License.
  • "Original Author" means the individual or entity who created the Work.
  • "Work" means the copyrightable work of authorship offered under the terms of this License.
  • "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
  • "License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, ShareAlike.

2. Fair Use Rights

Nothing in this license is intended to reduce, limit, or restrict any rights arising from fair use, first sale or other limitations on the exclusive rights of the copyright owner under copyright law or other applicable laws.

3. License Grant

Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:

  • to reproduce the Work, to incorporate the Work into one or more Collective Works, and to reproduce the Work as incorporated in the Collective Works;
  • to create and reproduce Derivative Works;
  • to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission the Work including as incorporated in Collective Works;
  • to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission Derivative Works.
  • For the avoidance of doubt, where the work is a musical composition:
    • Performance Royalties Under Blanket Licenses. Licensor waives the exclusive right to collect, whether individually or via a performance rights society (e.g. ASCAP, BMI, SESAC), royalties for the public performance or public digital performance (e.g. webcast) of the Work.
    • Mechanical Rights and Statutory Royalties. Licensor waives the exclusive right to collect, whether individually or via a music rights society or designated agent (e.g. Harry Fox Agency), royalties for any phonorecord You create from the Work ("cover version") and distribute, subject to the compulsory license created by 17 USC Section 115 of the US Copyright Act (or the equivalent in other jurisdictions).
    • Webcasting Rights and Statutory Royalties. For the avoidance of doubt, where the Work is a sound recording, Licensor waives the exclusive right to collect, whether individually or via a performance-rights society (e.g. SoundExchange), royalties for the public digital performance (e.g. webcast) of the Work, subject to the compulsory license created by 17 USC Section 114 of the US Copyright Act (or the equivalent in other jurisdictions).


The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. All rights not expressly granted by Licensor are hereby reserved.

4. Restrictions

The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:

  • You may distribute, publicly display, publicly perform, or publicly digitally perform the Work only under the terms of this License, and You must include a copy of, or the Uniform Resource Identifier for, this License with every copy or phonorecord of the Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Work that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Work itself to be made subject to the terms of this License. If You create a Collective Work, upon notice from any Licensor You must, to the extent practicable, remove from the Collective Work any credit as required by clause 4(c), as requested. If You create a Derivative Work, upon notice from any Licensor You must, to the extent practicable, remove from the Derivative Work any credit as required by clause 4(c), as requested.
  • You may distribute, publicly display, publicly perform, or publicly digitally perform a Derivative Work only under the terms of this License, a later version of this License with the same License Elements as this License, or a Creative Commons iCommons license that contains the same License Elements as this License (e.g. Attribution-ShareAlike 2.5 Japan). You must include a copy of, or the Uniform Resource Identifier for, this License or other license specified in the previous sentence with every copy or phonorecord of each Derivative Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Derivative Works that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder, and You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Derivative Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Derivative Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Derivative Work itself to be made subject to the terms of this License.
  • If you distribute, publicly display, publicly perform, or publicly digitally perform the Work or any Derivative Works or Collective Works, You must keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or (ii) if the Original Author and/or Licensor designate another party or parties (e.g. a sponsor institute, publishing entity, journal) for attribution in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; the title of the Work if supplied; to the extent reasonably practicable, the Uniform Resource Identifier, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and in the case of a Derivative Work, a credit identifying the use of the Work in the Derivative Work (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). Such credit may be implemented in any reasonable manner; provided, however, that in the case of a Derivative Work or Collective Work, at a minimum such credit will appear where any other comparable authorship credit appears and in a manner at least as prominent as such other comparable authorship credit.

5. Representations, Warranties and Disclaimer

UNLESS OTHERWISE AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE MATERIALS, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.

6. Limitation on Liability.

EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

7. Termination

  • This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Derivative Works or Collective Works from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
  • Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.

8. Miscellaneous

  • Each time You distribute or publicly digitally perform the Work or a Collective Work, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
  • Each time You distribute or publicly digitally perform a Derivative Work, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.
  • If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
  • No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
  • This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.