Skip to main content

History: Codeblocks and MinGW

Source of version: 2

Copy to clipboard
            {IMG(src="img/wiki_up/CBsplash.jpg"}{IMG}<font size="+2">__Using Ogre with Code::Blocks + MinGW C++ Toolbox__</font>
<br style="clear: both;">
__FORCETOC__
{{Layout_box4|1=
__WARNINGS!__


The SDK will not work with Code::Blocks 1.0 RC2. For the longest time, RC2 has been the __latest release__, and the advice has been to use a recent ''nightly build'', but as of February 2008, there finally is a new official release: 8.02. If you have 1.0 RC2 or an older nightly build of Code::Blocks, do scoot over to [http://www.codeblocks.org/|their site] and get the latest release!

The Ogre SDK for Code::Blocks + MinGW uses a modified version of MinGW called __MinGW C++ Toolbox__ which is a complete MinGW c++ installation with all required support tools including a modified version of libstdc++.

Be sure to restart your machine after installing the Windows version of the Ogre SDK. The installer creates an OGRE_HOME environment variable, that won't be recognized by Visual Studio or Code::Blocks until after Windows XP is restarted.
}}
!!Download the SDK


!!!Ogre [http://1.4.0|1.4.0] SDK for Code::Blocks + MingW
{{Layout_box4|1=
[http://prdownloads.sourceforge.net/ogre/OgreSDKSetup1.4.2_CBMingW.exe?download|SDK Download]
__NOTE:__ This SDK uses a modified version of libstdc++ with MingW gcc 3.4.5.

Make sure you have the latest [http://www.ogre3d.org/wiki/index.php/Codeblocks_and_MinGW#MinGW_C.2B.2B_Toolbox|Code::Blocks and MingW C++ Toolbox] installed.

Ogre's memory manager has been turned off for debug builds.
}}








!!!Ogre [http://1.2.5|1.2.5] SDK for Code::Blocks + MingW


{{Layout_box4|1=
[http://prdownloads.sourceforge.net/ogre/OgreSDKSetup1.2.5_CBMingW_p1.exe?download|SDK Download]
__NOTE:__ This SDK uses a modified version of libstdc++ with MingW gcc 3.4.5.
}}





{{Layout_box2|1=
!!!<u>Why use a modified version of libstdc++ v3 with MingW?</u>


}}
MingW will statically link libstdc++ (the library portion, not the STL) to each build ie each dll or exe.  This creates a problem when passing strings and any stream types across dll's.  Because the static linking has each copy of libstdc++ managing its own strings and streams, passing a string/stream to another dll and then having it modified there will trash memory.  Ogre has several dll's and does pass strings and streams around.  Do a debug build of Ogre with libstdc++ and then run in gdb and you find out quickly that a crash occurs in OgrePlatform_d.dll after the config window closes when it tries to modify/deallocate a string passed to it from OgreMain.dll.

A release build using libstdc++ "seems" to run fine for simple Ogre demos but if you start passing a lot of Ogre strings across dll's in a more complicated app, the app starts to misbehave after a while and crashes occur.

libstdc++ was rebuilt with the configure option --enable-fully-dynamic-string so that strings are dynamically allocated using the RTL and can be passed across the dll boundry.


wchar, wstring and wide streams for unicode support don't work in the standard pre-built libstdc++ that comes with g++ 3.4.5.  libstdc++ was rebuilt with wchar, wstring and wide stream to support wide strings so that Ogre [http://1.4.x|1.4.x] could be built.




{{Layout_box2|1=

!!!<u>The Ogre SDK Contents:</u>
}}
The Ogre SDK comes with:
* all the Ogre modules built for you ie the dll's and static archives
* the Ogre manual in HTML format
* API reference in the form of a windows compiled help (.chm)
* All header files (*.h) for the libs/dll are included
* Source code and project files for 30 demos that you can compile and run as a confidence test of the SDK installation and to see what Ogre can do.
* All media resources required for demos
** Material Scripts + shader programs
** Compositor Scripts
** Particle Scripts
** Meshes + Animations
** Textures



!!!!What you need to provide that is not supplied in the SDK
The SDK was built and tested with the following:

!!!!!MinGW C++ Toolbox


Download the __MinGW C++ Toolbox__ provided on the [http://prdownloads.sourceforge.net/ogre/MinGW_Toolbox_Setup_wr1.exe?download|Ogre SF files site].  MinGW must be setup before running Code::Blocks for the first time to make detection of MinGW go smoothly.

* [http://prdownloads.sourceforge.net/ogre/MinGW_Toolbox_Setup_wr1.exe?download|�49508�MingW C++ Toolbox:�49509�] 
 Download the installer package which will install the following in your mingw directory ie c:\mingw.
** gcc-core-3.4.5-20060117-1
** gcc-g++-3.4.5-20060117-1 with modified libstdc++ with dynamic string and wide string support [http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/|(online Manual)]
** w32api-3.8
** [http://binutils-2.17.50-20070129-1|binutils-2.17.50-20070129-1] [http://sourceware.org/binutils/docs-2.17/binutils/index.html|(online Manual)]
** mingw-runtime-3.11
** [http://gdb-6.3-2.exe|gdb-6.3-2.exe] [http://sources.redhat.com/gdb/current/onlinedocs/gdb_toc.html|(online Manual)]
** DrMingw [http://jrfonseca.planetaclix.pt/projects/gnu-win32/software/drmingw/index.html|(online manual)]





!!!!!MinGW Toolbox Install Guide


__Read__ the ((MinGW Toolbox Install Guide)) before running the toolbox installer.

{{Layout_box3|1=
__Note:__ 
For users migrating from CB + MinGW + STLPort to CB + MinGW there are a number of things you will have to do to ensure your project will build with Ogre SDK [http://1.2.x|1.2.x] or [http://1.4.x|1.4.x] and MinGW C++ Toolbox.  See the ((MinGW Toolbox project migration)) page}}




!!!!!Code::Blocks
* [http://www.codeblocks.org/|�49514�Code::Blocks�49515�] - Release 8.02


There is an official release of Code::Blocks as of February 2008. This supersedes the previous release candidate, which even the
Code::Blocks team didn't recommend anyway. For the longest time, to use Code::Blocks you had to have a nightly build of the development trunk,
certainly so if you wanted to compile OGRE. If you have used release candidate RC2 or one of the pre-release nghtly builds, do get the
new official release instead! In any case, the build files supplied with OGRE will ''not'' work with the old release candidate.




!!!!!Check Code::Blocks + MinGW installation
Make sure that Code::Blocks found your MinGW C++ Toolbox installation by following these instructions here: ((Code Blocks Compiler Setup))






!!!!!DirectX 9.0c August 2006 edition


* [http://www.microsoft.com/downloads/details.aspx?FamilyId=C72D9F1E-53F3-4747-8490-6801D8E8B4EF&displaylang=en|<font size="+1">Download the SDK</font>]. You will need the DirectX SDK if you plan to build and run in __debug mode__ when using __Direct3D9__ Rendering mode.  If you plan on building Ogre from source at a later date then you will need the DirectX SDK also. Note that this SDK doesnt work on Windows 2000 or less.

__Note:__ You do not need to download the dependencies package for Code::Blocks+MingW, everything you need is included in the SDK.



{{Layout_box2|1=
!!!!<u>Files in the Ogre [http://1.4.x|1.4.x] SDK:</u>


}}
The Ogre Core libraries and plugins:
||{{Layout_box3|1=
__Note:__ some may notice that there are very few import libs included in the Dependency package.  This is because MingW's linker (ld) can link directly to a dll that was built by it (just like on linux with gcc(ld)).  This way of linking is faster too.
}}||
{{Layout_box2|1=

!!!<u>Directory setup in Code::Blocks</u>
}}
{img src="img/wiki_up/CB_SetC_D.jpg" alt="CB_SetC_D.jpg"}

In the settings menu select __Compiler and Debugger__ to setup the directories.



{img src="img/wiki_up/CB_CompilerDir.jpg" alt="CB_CompilerDir.jpg"}

Setup the include directories for the compiler.



{img src="img/wiki_up/CB_LinkerDir.jpg" alt="CB_LinkerDir.jpg"}

Setup the lib directories for the linker.  Note that DirectX SDK lib is not used.  The import libs in the Ogre dependencies will be used instead since MingW cannot link directly to the libs provided in the DirectX SDK.



{img src="img/wiki_up/CB_ResDir.jpg" alt="CB_ResDir.jpg"}

Include directory for windows resource compiler.



{{Layout_box2|1=

!!!<u>Building</u>
}}

To build Ogre in Code::Blocks, open the __Ogre.workspace__ file. If you have installed or are using Code::Blocks + MinGW + STLPort, open the ''Ogre_stlp.workspace'' file.

{img src="img/wiki_up/CB_BuildWorkspace.jpg" alt="CB_BuildWorkspace.jpg"}

In the build menu select __Build Workspace__. This will build the debug and release targets of all projects listed in the workspace manager window.

The build process will take about 30 minutes on a AMD Athlon XP 2000+ with 512Megs if all projects are built.

You will (hopefully) find the newly build sample demos under:
* ogrenew\Samples\Common\bin\Debug
* ogrenew\Samples\Common\bin\Release



!!!!<u>Building Ogre Core DLLs</u>
If you don't want to build the samples choose __Save Workspace as...__ under the file menu, enter __OgreCore_stlp.workspace__ for the file name and save. Next, close the samples and projects in the workspace that you don't want, and save again. You can use the OgreCore_stlp workspace to re-build Ogre each time you update from CVS.

Here is an example of the minimum Ogre Core DLLs that must be built for the SDK. This assumes that you are utilizing the BSP and Octree scenemanagers, both DirectX and OpenGL renderers, CG shaders, and CEGUI.

{img src="img/wiki_up/CB_OgreCoreWS.jpg" alt="CB_OgreCoreWS.jpg"}

__Note:__ Code::Blocks builds the projects in the order listed in the Manager window. Dependencies have been set up to insure that if you decide to build a demo before the core libraries, the core library projects ''will'' be built first.

!!((CodeBlocks Ogre SDK Tips))
!!((CodeBlocks MinGW FAQ))
((Category:Setup))
((Category:Code Blocks))


        

History

Information Version
Thu 23 of Sep, 2010 23:23 GMT-0000 Beauty added page alias name 36
Mon 04 of Jan, 2010 13:53 GMT-0000 jacmoe 35
Wed 30 of Dec, 2009 05:28 GMT-0000 jacmoe 34
Wed 30 of Dec, 2009 05:10 GMT-0000 jacmoe 33
Wed 30 of Dec, 2009 05:07 GMT-0000 jacmoe 32
Wed 30 of Dec, 2009 04:57 GMT-0000 jacmoe 31
Wed 30 of Dec, 2009 04:54 GMT-0000 jacmoe 30
Wed 30 of Dec, 2009 04:53 GMT-0000 jacmoe 29
Wed 30 of Dec, 2009 04:50 GMT-0000 jacmoe 28
Wed 30 of Dec, 2009 04:48 GMT-0000 jacmoe 27
Wed 30 of Dec, 2009 04:30 GMT-0000 jacmoe 26
Wed 30 of Dec, 2009 04:30 GMT-0000 jacmoe 25
Wed 30 of Dec, 2009 04:28 GMT-0000 jacmoe 24
Wed 30 of Dec, 2009 04:27 GMT-0000 jacmoe 23
Wed 30 of Dec, 2009 04:21 GMT-0000 jacmoe 22
Sat 26 of Dec, 2009 23:58 GMT-0000 jacmoe 21
Sat 26 of Dec, 2009 23:55 GMT-0000 jacmoe 20
Sat 26 of Dec, 2009 23:46 GMT-0000 jacmoe 19
Sat 26 of Dec, 2009 23:45 GMT-0000 jacmoe 18
Sat 26 of Dec, 2009 23:37 GMT-0000 jacmoe 17
Sat 26 of Dec, 2009 23:33 GMT-0000 jacmoe 16
Fri 18 of Dec, 2009 18:51 GMT-0000 jacmoe 15
Fri 18 of Dec, 2009 18:45 GMT-0000 jacmoe 14
Fri 18 of Dec, 2009 18:44 GMT-0000 jacmoe 13
Fri 18 of Dec, 2009 18:43 GMT-0000 jacmoe 12
  • «
  • 1 (current)
  • 2