Codeblocks and MS Visual Studio         Installing the Ogre SDK for Visual C++ 2008 & Code::Blocks

%prevogreNo value assigned|85%)}Image ---

Installing the Ogre SDK for Visual C++ 2008 & Code::Blocks

Use this guide to install the precompiled OGRE SDK for Visual C++ 2008 & Code::Blocks. Once you have OGRE downloaded and setup, learn how to setup your first application.{DIV}

Software

  1. Download and install Microsoft Visual C++ Express 2008
  2. Download and install the Ogre SDK for Visual C++ 2008. (This article was written using the 1.4.7 release)
  3. Download and install Code::Blocks
    1. When installing Code::Blocks select Microsoft Visual C++ 2005/2008 as the default compiler

The demos in Code::Blocks

Opening the demos in Code::Blocks

  1. Run Code::Blocks
  2. If you did not already set Microsoft Visual C++ 2005/2008 as the default compiler, do so via the Settings->Compiler and debugger... menu.
  3. Open Samples_vc9.sln; if you installed the SDK in the default location this is c:\OgreSDK\samples\Samples_vc9.sln
  4. Answer "Yes" to all of the questions.
  5. File->Save workspace as... to save all the open projects as a workspace. A good place to save this is e.g. c:\OgreSDK\samples\Samples_cb.sln

Making the demos build and run in Code::Blocks

To begin with the demos will not build and run correctly. This is partly due to Samples_vc9.sln containing incorrect information, and partly due to differences between the Code::Blocks and Visual C++ IDEs.

  1. In the left hand panel, select the project (demo) you would like to build. Right click on it and select the "Activate Project" menu item
    1. Trying to build the project without activating it will cause Code::blocks to build using its application wide build settings instead of the project-specific build setttings. This will result in a myriad of errors, most immediately ones like this: fatal error C1083: Cannot open include file: 'ExampleApplication.h'
  2. Change the link options for the build targets. Right click on the demo project and select "Properties...". Select the "Build targets" tab. Select the either target in the list on the left and click on the "Build options..." button. Open the "Linker Settings" tab.
    1. Put quotes around "/pdb:..\..\bin\Debug Win32\Demo_demoname.pdb" under "Other linker options" for the debug target
      1. If you don't do this you get an error that ..\..\bin\Debug can't be found when running the debug target
    2. Under "link libraries" add user32 to both build targets
      1. If you don't do this the linker spits out symbol errors such as: unresolved external symbol _imp__MessageBoxA@16 referenced in function _WinMain@16
    3. Codeblocks_visual_c--_demo_linker_settings_complete.png
    4. The project will now build, but it won't run correctly.
  3. Change the execution options for the build targets. Right click on the demo project and select "Properties...". Select the "Build targets" tab.
    1. Select the "Debug Win32" target
    2. Change the "Execution working dir" to "..\..\bin\debug"
      1. If you don't change the working directory, you will get the error "This application has failed to start because OgreMain_d.dll was not found..." When your program runs, the loader looks for the .dll files as well as the cfg files that tell ogre where to load media from in the current path.
    3. Select the "Release Win32" target
    4. Change the "Execution working dir" to "..\..\bin\release"
    5. Codeblocks_visual_c--_demo_working_directory_complete.png
  4. Build and run either target for this demo. They'll both work!
Call to undefined function mb_split()Call to undefined function mb_split()Call to undefined function mb_split()Call to undefined function mb_split()