Using Net Beans With Irrlicht


NetBeans 6.1 - At A Glance

The Good

  • Code completion
  • Class/Function/Variable Navigator
  • Debugger on Windows works fine.
  • Nice integration with Version Control Systems such as CVS, Mercurial, and SVN.
  • Builds all combination's of shared, static, debug, release, Linux, and Windows versions of the Irrlicht library.

The Not So Good

  • C++ Refactoring is experimental. Tests on small projects appear to work fine.
  • Debugger on Linux has trouble with Irrlicht - unexpectedly terminates and sometimes hangs.
  • No Concept of Workspaces or Project dependencies. Add section on "Groups" and dependency setup (props->linker->add project).
  • A single project isn't really platform independent. Requires a platform specific sub-configuration.

NetBeans 6.1 is a free, Java based, cross-platform IDE which allows you to develop C/C++ applications. Features related to C/C++ development using NetBeans may be found on the NetBeans IDE - C/C++ features page.

NetBeans Building the Static Irrlicht Library on Windows XP

Installation & Setup

Various sections of this article require that you setup an environment variable named IRRLICHT_SDK to point to the root location of your Irrlicht SDK installation. For example, if you unzipped or checked out the source via Subversion to "c:\dev\irrlicht", you will need to set IRRLICHT_SDK=c:\dev\irrlicht.

--Windows Prerequisites--

The NetBeans C++ Plugin supports both the Cygwin and MinGW environments. This tutorial uses MinGW/MSYS in order to avoid having to include cygwin.dll with your application.

MinGW Installation

  1. Download and install MinGW-5.1.4.exe.
  2. Make sure to include (check) the "g++ compiler" component when the install asks you to select components. Note - do NOT include "MinGW Make".
  3. Accept the default installation directory: "C:\MinGW"

After the installer finishes, the C/C++ compilers (gcc,g++) are now installed in the "c:\MinGW\bin" directory. The next step is to install the GNU Debugger (gdb) into the same directory:

MinGW gdb Installation

  1. Download the gdb archive file gdb-6.8-mingw-3.tar.bz2
  2. Expand the contents of gdb-6.8-mingw-3.tar.bz2 into "C:\MinGW".

When finished, "C:\MinGW\bin" should now contain "gdb.exe" and "gdbserver.exe". At this point you still need make.exe and a few other file utilities (rm, cp, etc.). These utilities are located in MSYS.

MSYS Installation

  1. Download and install MSYS-1.0.10.exe.
  2. Accept the default installation directory: "C:\msys\1.0".
  3. Enter "C:/MinGW" when it asks for the location of your MinGW installation.

Now that MSYS (1.0.10) is installed, it needs to be updated to 1.0.11. If you're re-reading these instructions because your NetBeans projects are giving you an error when you clean them, then you likely didn't update to 1.0.11 properly. Version 1.0.11 contains an updated version of rm.exe which is used to clean NetBeans projects.

  1. Download the 1.0.11 core update coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2.
  2. Expand the contents of coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2 (bin, info, lib, and man) into "C:\MSYS\1.0\".

DirectX 9 Support

With NetBeans, the Irrlicht shared and static libraries can be built with DirectX 9 support. In order to do so, you'll need to have the latest DirectX 9 SDK installed (MinGW doesn't supply all of the required headers). At the time of this writing (08/2008), the latest SDK may be downloaded here:

After you install the DirectX SDK, you'll need to create an environment variable named DXD9_SDK (used by the NetBeans Irrlicht project). This environment variable needs to point to the root directory of your DirectX SDK installation. For example, if you accepted the default location, the DirectX SDK was installed to:

  • C:\Program Files\Microsoft DirectX SDK (August 2008)

Unfortunately the DXD9_SDK environment variable can NOT be set to this as it is. The reason for this is that the DXD9_SDK environment variable is passed to the MinGW g++ compiler verbatim. Therefore invoking the compiler would appear something like this:

  • g++ -I C:\Program Files\Microsoft DirectX SDK (August 2008)/include

This causes compiler errors because of the colon, back-slashes, spaces, and parenthesis. So what should DXD9_SDK be set to? Easy:

  • C\:/Program\ Files/Microsoft\ DirectX\ SDK\ \(August\ 2008\)/

Maybe not so easy... Here are the rules to follow for creating a proper DXD9_SDK environment variable:

  1. First, replace existing back-slash characters "\" with forward slashes "/".
  2. Second, insert a back-slash character"\" in front of every colon, space, and parenthesis.

NetBeans C++ Plugin Setup

Instructions for installing the NetBeans C++ Plugin may be found in the section named Downloading C/C++ Support

After the plugin is installed the C++ Plugin will need to be configured to use MinGW. For Win32 projects, your MinGW Tool Collection config should look like this:

--Linux Prerequisites--

You'll need the same libraries/packages outlined in "Things You Need" found at Compiling On Linux

--Irrlicth SDK NetBeans Project Installation--

If you want to build Irrlicht with NetBeans, you can download the native NetBeans Irrlicht project (nbproject) here:

Unzip the contents of into the root directory of your Irrlicht SDK directory {IRRLICHT_SDK}. When finished, the Irrlicht SDK will then contain:


Building Irrlicht - These Instructions are not for Linux!

To build Irrlicht with the supplied NetBeans project file (, simply:

  1. Open the Irrlicht NetBeans project file by selecting the menu item "File|Open Project" and then navigate to the root location of your Irrlicht SDK installation.
  2. Select the appropriate "Project Configuration" (Win32/Linux, Static/Shared, Release/Debug):
  3. Select the menu item "Build|Build Main Project (F11)" or "Build|Clean and Build Main Project (Shift+F11)".

Depending on the "Project Configuration" you choose, the following output will be generated by the build:

  • "Win32-Shared-Debug" - lib\Win32-gcc\Irrlicht_d.dll
  • "Win32-Shared-Release" - lib\Win32-gcc\Irrlicht.dll
  • "Win32-Static-Debug" - lib\Win32-gcc\Irrlicht_static_d.a
  • "Win32-Static-Release" - lib\Win32-gcc\Irrlicht_static.a
  • "Linux-Static-Debug" - lib\Linux\Irrlicht_static_d.a
  • "Linux-Static-Release" - lib\Linux\Irrlicht_static.a

Note that these generated files are located off of the root directory of your Irrlicht SDK.

Where are the shared/dynamic link .lib files? There aren't any - with MinGW your application will link directly to the appropriate .dll file.

Creating A NetBeans Project For 01.HelloWorld

This section will walk you through the necessary steps for creating a NetBeans project for the existing Irrlicht 01.HelloWorld example application. When you are finished:

  • The project will contain four configurations: static-debug, static-release, shared-debug, and shared-release.
  • The output (application binaries) will be saved to "{IRRLICHT_SDK}\bin\win32-gcc\".

Step 1. - Create the NetBeans Project

This step will create the NetBeans Project inside the existing "{IRRLICHT_SDK}\examples\01.HelloWorld" folder.

Start NetBeans and select the menu item "File|New Project".

  • Set "Category" = "C/C++".
  • Set "Projects" = "C/C++ Application".

Click "Next".

  • Set "Project Name" = "01.HelloWorld".
  • Set "Project Location" = "{IRRLICHT_SDK}\examples".

Click "Finish".

When finished, the 01.HelloWorld folder will now contain a file named "" and a sub-directory named "nbproject". To complete this step, we'll add the existing 01.HelloWorld source code file (main.cpp) to the project by:

  1. Right click the "Source Files" node in the Project tab and select "Add Existing Item".
  2. Select "main.cpp" located in the 01.HelloWorld directory.

Step 2. - Create the Project Configurations

When you create a new NetBeans project file it generates two default project configurations named "debug" and "release". We are going to modify these configurations to build debug and release applications that link statically to the Irrlicht static libraries previously generated. After that we'll copy these configurations and make a couple of minor modifications in order to build the debug and release applications that link dynamically to the Irrlicht dynamic libraries that were previously generated.

In order to create/modify a projects configurations we must first display the "Project Properties" dialog by right clicking the top level "01.HelloWorld" node and selecting "Properties" or by clicking on the "01.HelloWorld" Properties menu item under the "File" menu:

Click the Manage Configurations button to display the existing "Debug" and "Release" configurations and rename them to "Static-Debug" and "Static-Release":

Next we'll setup the "C++ Compiler" and "Linker" options for the "Static-Debug" configuration (should be active).

C++ Compiler Options:

  • Include Directories - ../../include
  • Preprocessor Definitions - _IRR_STATIC_LIB_, WIN32, _WINDOWS, __GNUWIN32__, _DEBUG

Include Directories note - Why not use "${IRRLICHT_SDK}/include"? If you substitute "../../include" with "${IRRLICHT_SDK}/include", the project will build without errors. Unfortunately using the IRRLICHT_SDK environment variable will cause source code "navigational errors". In other words, the source code editor will flag "include <irrlicht.h>" as a NOT FOUND error and you won't be able to right click and select "Navigate|Go to Include" as a means of opening the "irrlicht.h" source file...

Linker Options:

  • Output - dist/Static-Debug/MinGW-Windows/01.helloworld
  • Libraries - Irrlicht_static_d.a (located in {IRRLICHT_ROOT}/lib/win32-gcc), gdi32, opengl32

Output note - Sending the executable to the "expected" Irrlicht example bin directory (../../bin/Win32-gcc/01.helloworld.exe) works as you would expect it to. However, when you attempt to run (Run | Run Main Project (F6)) the application within the NetBeans IDE a "No such file or directory" error is raised. On the other hand, Debugging works (Run | Debug Main Project (Ctrl+F5)). For now, leave it set to the default "dist/Static-Debug/MinGW-Windows/01.helloworld" (created off of the 'examples\01.HelloWorld directory) until this problem is fixed. Issue reference:

Even though we choose the default (dist/Static-Debug...), the appropriate media files will be correctly located without source modifications because the default run command will execute the application with a current directory of (../examples/01.HelloWorld).

Libraries note - Add the Irrlicht_static_d.a library using the "Add Library File..." button. The other two libraries add using the "Add Library..." button and type in the names.

  Be certain the libraries are in this order:

Step 3. - Build and Run 01.HelloWorld

To build the 01.HelloWorld application simply select the menu item "Build | Build Main Project (F11)". The compiler and linker messages will be displayed in the NetBeans "Output" window. If the build was successful, you will see the message "Build successful. Exit value 0.". If the compiler encounters errors, those errors will be displayed in the "Output" window as well. You may double-click the error message and NetBeans will open the corresponding source file and position the editor to the line in question.

After a successful build, you may run your application by selecting the menu item "Run | Run Main Project (F6)" or you may choose to debug your project: "Run | Debug Main Project (Ctrl+F5)". Note that you may set breakpoints by positioning the editor cursor on the line to break on and then press "Ctrl+F8".

Step 4. - Create the Static Release Configuration

We'll start setting up the Static-Release configuration for 01.HelloWorld by displaying the Project Properties dialog - "File | "01.HelloWorld" Properties".

Next change the active configuration from "Static-Debug" to "Static-Release". Now we're ready to set the C++ Compiler and Linker options:

C++ Compiler Options:

  • Include Directories - ../../include
  • Preprocessor Definitions - _IRR_STATIC_LIB_, WIN32, _WINDOWS, __GNUWIN32__, NDEBUG
  • Strip Symbols - checked.

Linker Options:

  • Output - dist/Static-Release/MinGW-Windows/01.helloworld
  • Strip Symbols - checked
  • Libraries - Irrlicht_static.a (located in {IRRLICHT_ROOT}/lib/win32-gcc), gdi32, opengl32

It's important to remember when adding "Irrlicht_static.a" to use the "Add Library File..." button, and use "Add Library..." for the other two libraries.

Creating Your Own Irrlicht Project

Debugging With NetBeans


 Q: Can Irrlicht be compiled with DirectX support using NetBeans?
 A: Yes, this more of an issue related to MinGW than NetBeans. See the section named "Install & Setup".

 Q: The debugger doesn't work on Linux.  Why?
 A: It's a known bug: url 

 Q: Do I have to use MinGW?
 A: No. You can also use Cygwin.

 Q: Can I use Microsoft's compiler/linker with NetBeans?
 A: Really?

 Q: Can I link to libraries generated by Visual Studio?
 A: Technically - yes.  Practically - no. See Mixing Objects. (currently down)...

 Q: Does the NeBeans C++ plugin have a users forum?
 A: Yes -