3 min read

(For more resources related to this topic, see here.)

Creating a new empty project

Let’s get started by creating a new project from scratch. Follow the steps that are given for the IDE and operating system of your choice.

Visual Studio

Open Visual Studio and select File | New | Project from the menu. Expand the Visual C++ item and select Win32 Console Application. Click on OK to continue:

In the project wizard click on Next to edit the Application Settings. Make sure Empty project is checked. Whether Windows application or Console application is selected will not matter. Click on Finish and your new project will be created:

Let’s add a main source file to the project. Right-click on Source Files and select Add New Item…|. Choose C++ File(.cpp) and call the file main.cpp:


Use the CodeBlocks project wizard to create a new project as described in the last chapter. Now double-click on main.cpp to open this file and delete its contents. Your main source file should now be blank.

Linux and the command line

Copy the make file of one of the examples from the Irrlicht examples folder to where you wish to create your new project. Open the make file with a text editor of your choice and change, in line 6, the target name to what you wish your project to be called.

Additionally, change, in line 10, the variable IrrlichtHome to where you extracted your Irrlicht folder. Now create a new empty file called main.cpp.


Open Xcode and select File | New Project. Select Command Line Tool from Application. Make sure the type of the application is set to C++ stdc++:

When your new project is created, change Active Architecture to i386 if you are using an Intel Mac, or ppc if you are using a PowerPC Mac.

Create a new target by right-clicking on Targets, select Application and click on Next. Target Name represents the name of the compiled executable and application bundle:

The target info window will show up. Fill in the location of the include folder of your extracted Irrlicht package in the field Header Search Path and make sure the field GCC_ PREFIX_HEADER is empty:

Right-click on the project file and add the following frameworks by selecting Add Existing Frameworks…|:

  • Cocoa.framework
  • Carbon.framework
  • IOKit.framework
  • OpenGL.framework

Now, we have to add the static library named libIrrlicht.a that we compiled in Chapter 1, Installing Irrlicht. Right-click on the project file and click on Add | Existing Frameworks…. Now click on the button Add Other… and select the static library.

Delete the original compile target and delete the contents of main.cpp.

Time for action – creating the main entry point

Now that our main file is completely empty, we need a main entry point. We don’t need any command-line parameters, so just go ahead and add an empty main() method as follows:

int main()
return 0;

If you are using Visual Studio, you need to link against the Irrlicht library. You can link from code by adding the following line of code:

#pragma comment(lib, "Irrlicht.lib")

This line should be placed between your include statements and your main() function.

If you are planning to use the same codebase for compiling on different platforms, you should use a compiler-specific define statement, so that this line will only be active when compiling the application with Visual Studio.

#if defined(_MSC_VER)
#pragma comment(lib, "Irrlicht.lib")

Subscribe to the weekly Packt Hub newsletter. We'll send you this year's Skill Up Developer Skills Report.

* indicates required


Please enter your comment!
Please enter your name here