Mar 082009
 

SFML, the Simple and Fast Multimedia Library, has tutorials for Code::Blocks, plain GCC, Visual Studio, but not Netbeans. Well, I like Netbeans. This tutorial isn’t perfect – the library names are fine for GNU/Linux and not for Windows, refer to the SFML howto for Windows to determine what library names to use. This will show you how to set up a Netbeans project to use SFML.
First things first – as I am running Gentoo on an x86_64 system (AMD64), I compiled the libraries myself. Don’t forget to do that if that’s your thing – I spent two evenings wondering why it wasn’t working.

First, go to Tools > Options and find the C/C++ heading. If it’s not there, you have to first create a C++ project to activate the feature. I have my SFML headers under ‘/home/alg/workspace/SFML-1.4/include – replace that path with the INCLUDE path of wherever you downloaded the SFML libs. Don’t use the ‘SFML’ subdirectory – use the ‘INCLUDE’ directory.

Tools > Options > Code Assistance > C++ Compiler

Tools > Options > Code Assistance > C++ Compiler

Next, on to the project itself. Right-click on the project in the project list and go to Properties.

Right click on project - go to properties

Right click on project - go to properties

Now, you need to be aware that there are at least two configurations – Debug and Release. Unless you want to debug output from SFML, you should change the Configuration to “All Configurations” so that both testing and release get affected by the following changes, otherwise when you compile the release.. It’ll break and you may have forgotten why.

Configuration - All configurations

Configuration - All configurations

Go to Build > C++ Compiler, and enter/select the SFML include directory in the ‘Include Directories’ option.

Setting the project's include directories

Setting the project's include directories

The next and last step is to go to the linker and add the libraries themselves. The button on the right comes in very handy here.

On which line do we add it? The one that says Libraries!

On which line do we add it? The one that says Libraries!

So, if you click on the three dots, you get the following window. I chose to store the libraries as full paths, it probably doesn’t make a huge difference in the context of creating the program – but maybe in the outside world you just want to have the libraries in the same folder to make your life easier.

Adding libraries!

Adding libraries!

This should be all you need to do… Now you’re on your own, all alone with the internet to help you. Happy hacking! Please let me know if anything is incorrect or if you have any additions to make.

  2 Responses to “Howto: SFML with Netbeans”

  1. hi, just wanna ask help for setting up sfml in windows through netbeans
    i tried many times, but it always returns an error:

    #error This operating system is not supported by SFML library

    thank you

  2. Alright – Are you doing exactly the same thing that I am doing in this tutorial? What version of Windows do you have.. And which version of SFML did you download?