Irrlicht Engine logo

Tutorial: Irrlicht & Code::Blocks by Alvaro F. Celis

Things you'll need:
latest version of codeblocks:
www.codeblocks.org

MSVC toolkit: (MS's free version of their MSVC 2003 C++ compiler)
http://www.microsoft.com/downloads/details.aspx?FamilyId=272BE09D-40BB-49FD-9CB0-4BFA122FA91B&displaylang=en

Microsoft .Net framework:
you can get it here:
http://msdn.microsoft.com/netframework/downloads/framework1_1/
or here:
http://www.asp.net/download-1.1.aspx?tabindex=0&tabid=1

MS plattform SDK: use the 2003 version; the 2005 gives problems, link here:
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm

Or, just grab the zipped file with the "Include" and "lib" folders here:

http://www.danielpatton.com/afecelis/files/MicrosoftSDK.zip

MS's DX sdk: huge download. Try to get just the "Include" and "Lib" folders. They're all you need.
You can grab the zipped version I uploaded here:
http://www.danielpatton.com/afecelis/files/DXSDK.zip
It's an old 2004 version so it still has the dx8 stuff that latest sdks report errors on, and it's the one used with this tutorial. Unzip it to C: a folder "DXSDK" will be created with the required "include" and "lib" folders.

After getting the SDK, you must create 2 system variables for MS sdk's include and lib folders. Right click on "My Computer", select the "Advanced" tab and choose "Environment Variables". In the lower part (system variables) hit "new" to add a variable called "INCLUDE" and add the sdk's "Include" folder path; usually C:\Program Files\Microsoft SDK\include. Add another new variable called "LIB" and add the sdk's "Lib" folder; usually located at: C:\Program Files\Microsoft SDK\Lib.

This will ensure that libraries we call globally will be found in the system.
Ok, now on to the screenshots:

01. Launch codeblocks, go to project, import, ms visual c++ project:



02. Look for the dsp project in Irrlicht's "source" folder; (remember to uncompress the zip with the source!) once you find it, select it and hit open. It will ask which compiler you want to use (I used MSVC toolkit 2003) and if you want to build in debug or release mode; make your pick! Wait a bit while it loads all of Irrlicht's files!



03. Select your imported project (Irrlicht), right click on it and go to "build options"



04. Select "Irrlicht -Win32release" (in my case I chose to build the dll in release mode), verify on the right you're using the proper compiler (in this case the MSVC toolkit 2003):



Newer codeblocks versions will have the options in 3 separate tabs (marked in red) but you don't have to worry about what to tick; just leave the ones that come by default when importing the dsp project.

 

05. Select the second tab (linker options) and add in the libraries that show up in the screenshot; one by one:


add in the following libraries:

kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib

Remember to exclude libci.lib in the "other linker options" menu by typing:

/NODEFAULTLIB:libci.lib

This will solve the missing "libci.lib" error report.


06. Go on to the third tab (directories), in the compiler options; Add the necesary include folders in the same order as in the screenshot: note: it will ask if you want to keep the folder as relative path; answer "no" to this option to make the path absolute:


NOTE: SINCE IRRLICHT 0.10 YOU MUST ALSO INCLUDE THE ZLIB FOLDER

 

07. Do the same in the linker tab, add the necesary lib folders as in the screenshot (again, answer "no" to relative paths); once done, hit "OK", go to file and save your project as "irrlicht" in the source folder:


NOTE: SINCE IRRLICHT 0.10 VISUALSTUDIO'S LIB FOLDER CHANGED FROM "VisualStudio" to "Win32-VisualStudio". Make sure you're linking to the proper "lib" folder.

08. Right click on your "Irrlicht" project and select "compile", you may also use the shortcut ctrl-f9 or hit the 12th icon from left to right, the one that looks like a dented wheel.


09. Rejoice! 0 errors, 0 warnings. Go to Irrlicht's release folder and pick up your dll.



10. the dll, ready to be used:



And that's it. Just tested it with version 0.12 and works perfectly if you follow the steps mentioned above and download all the necessary files.

Advantages of using this IDE (Codeblocks) plus the MSVC toolkit:

  1. Both tools are free

  2. Codeblocks imports MSVC 6.0 and 7.0 projects without problems.

  3. You can compile using DirectX or Opengl straightforward.

Finally, to make things even cooler, Cmoibenlepro made a template for Irrlicht projects; Grab it here, and unzip it into your "templates" folder in your codeblocks installation:
http://www.danielpatton.com/afecelis/codeblocks/templates.zip

After unzipping it you'll just have to go to "Project" - "new project" and select the Irrlicht project icon. Then replace the code in "main.cpp" with your own.

So now you guys can compile your own version of the engine (dll) as well as projects using the Irrlicht engine. (I hope to add project creation with this same set of tools on a second version of this tutorial).

PART 2: CREATING AND COMPILING APPLICATIONS WITH CODEBLOCKS AND MSVCTOOLKIT 2003

01. Grab the template files created by Cmoibenlepro here:

http://www.danielpatton.com/afecelis/codeblocks/templates.zip

02. Unzip the file to Codeblock's "templates" folder; normally located at

C:\Program Files\CodeBlocks\share\CodeBlocks\templates

Now we can start creating our project.

03. Launch codeblocks, and go to "project" - "new project"



04. If you unzipped the "templates" file properly, you'll have an Irrlicht project Icon to create a project. Select it.



05. Hit the "create" button, and choose a location for your project. By default the project will be named "Irrlicht" but you can change it. I'm calling this project "test", and I'm saving it inside the "Irrlicht" folder in a new folder also called "test".


06. Hit the "save" button and the application will be created automatically for you, in this case using the default cpp template for the "hello world" example.



Hit the "plus" in "Irrlicht Project", go to "sources" and there you'll find your "main.cpp" file.

 

07. If you right click on "Irrlicht Project" and check its "build options" you'll see everything has been set up by default to some folders. Make any corrections to the paths according to how you use the engine in your system.



08. Hit the compile button, or go to the "compile" menu and click on "compile" or use the ctrl+f9 shortcut. Your application is compiled into an .exe!



09. Check the lower horizontal part of Codeblocks; no errors reported!


10. Now check your "test" folder and look for your .exe. The executable file takes the name of the project by default; in this case "test.exe"

If you double click on it you'll get errors since we still haven't copied our dll into the application folder nor have we added the necessary media for the application to run.

 

11. Copy the dll we created in the first part of this tutorial in to your "test" folder. The dll must reside in the same folder as the .exe. Also create a folder called "media" and copy "sydney.md2" and "sydney.bmp" from Irrlicht's "media" folder into it.



12. Now we got all the required things for our app to run properly. Double click on "test.exe" and watch good old sydney move !



So that concludes and rounds up our little tutorial. It also took us 10 screenshots for the second part, great! Next thing you guys can do is create your own stuff by replacing the default code with yours after creating the application.

I hope you found this tut useful.

Written By:

Alvaro F. Celis
"afecelis"
Irrlicht Engine Forum Admin.
afecelis@gmail.com

August 27, 2005



 

 

 


Valid XHTML 1.0! Valid CSS!


Irrlicht Engine and Irrlicht Engine webpage © 2003-2005 by Nikolaus Gebhardt