NetBeans IDE and C++

Introduction

This tutorial demonstrates how to configure NetBeans to create and build C++ projects. We use the NetBeans IDE version 6.5, g++ v4.4.1, and Fedora v11. The operating system runs within Sun Virtual Box 3.0.0 r52128, which does not affect the tutorial in any way save for the appearance of the figures. Given the nature of Linux in general, these steps should apply to any modern version of Linux, g++, Gnome, and NetBeans.

Although NetBeans is commonly associated with Java, the NetBeans IDE and C Plus Plus are also compatible. NetBeans is actually a development environment that is extremely flexible. Adapting NetBeans to work with Cpp programs is time well spent.

Figure 1

From the Gnome Desktop, click System/Administration / Add/Remove Software:

Step 1: Type netbeans into the Find field.

Step 2: Click the Find button

Step 3: Wait a few minutes while the Find executes. When the results window populates, check the box adjacent to Integrated Development Environment (IDE).

Step 4: Click the Apply button

Figure 2

Step 5: A window will appear: confirm the installation of several additional packages by clicking Install. This will download Netbeans and install the IDE on your system.

Figure 3

Step 6: Wait a few minutes as the installation of NetBeans completes. From the main menu of Gnome, click Applications / Programming / NetBeans 6.5

Figure 4

Step 7: After NetBeans loads, click Tools / Plugins.

Figure 5

Step 8: Click the check box adjacent to the C/C++ plugin

Step 9: Click the Install button

Figure 6

Step 10: From the NetBeans Main Menu, click File / New Project.

Figure 7

Step 11: Under Categories, select C/C++

Step 12: Under Projects, select C/C++ Application

Step 13: Click the Next button

Figure 8

Step 14: Type the name of the project. We use HelloWorld. Remember that this name will be used by NetBeans to create files and directories; Linux is case-sensitive.

Step 15: Click the Finish button.

Figure 9

Step 16: Right-Click on the Source Files Folder. A context menu will appear.

Step 17: Select New / Main C File.

Figure 10

Step 18: Enter the file name main.cpp (remember that Linux file names are case sensitive)

Step 19: Click the Finish button.

Figure 11

Step 20: Right Click on the HelloWorld project. A Context Menu will appear.

Step 21: Select Properties.

Figure 12

Step 22:Under Project Properties, select C++ Compiler.

Step 23: Under Include Directories, enter the file path for the g++ headers:

/usr/include/c++/4.4.1

Click the OK button.

Figure 13

Step 24: Under Project Properties, select Linker.

Step 25: In the Tool text box, enter g++ (case sensitive)

Step 26: Click the Apply button


Figure 14

Step 27: Modify the code that was automagically created by NetBeans. Add the lines that are labeled with the "Add" comment. Ignore squiggles. The code will still build even though NetBeans doesn't like it.

Figure 15

Step 28: From the NetBeans Main Menu, click Run / Run Main Project. The project will build and execute. Any errors will appear in the tiny window near the bottom of the screen.

Figure 16

The expected output of the code.

Happy Coding!


The sample program

/* 
 * File:   main.cpp
 * Author: nicomp
 *
 * Created on December 24, 2009, 12:47 AM
 */

#include <stdio.h>
#include <stdlib.h>
#include <iostream>     // Add

using namespace std;    // Add
/*
 * 
 */
int main(int argc, char** argv) {

    printf("\n Hello World\n");     // Add
    cout << "\n Hello from cout\n"; //  Add

    return (EXIT_SUCCESS);
}

List of Figures

Figure 1
Figure 1
Figure 2
Figure 2
Figure 3
Figure 3
Figure 4
Figure 4
Figure 5
Figure 5
Figure 6
Figure 6
Figure 7
Figure 7
Figure 8
Figure 8
Figure 9
Figure 9
Figure 10
Figure 10
Figure 11
Figure 11
Figure 12
Figure 12
Figure 13
Figure 13
Figure 14
Figure 14
Figure 15
Figure 15
Figure 16
Figure 16

More by this Author


Comments 5 comments

dusanotes profile image

dusanotes 6 years ago from Windermere, FL

Sorry, Nycomp, I'm not smart enough to work through all this esoteric brain stuff. I can't tell if you did a fantastic, good, or poor job. But I thank you for presenting it. Who knows, someday I may come back to it and you'll really save my day. Thanks, Don White


psychicdog.net profile image

psychicdog.net 6 years ago

Fascinating...Bit of a naive question but is cpp the main lang for operating systems as opposed to webpages?


nicomp profile image

nicomp 6 years ago from Ohio, USA Author

@psychicdog.net: Yes and no. 'C' is still the language of choice for flat-out speed and efficiency when programming an operating system. Short of assembly language programming, 'C' is the fastest language for that purpose. 'C++' is the next generation of 'C' and is also popular for low-level programming such as video games and electronic devices. There are trade-offs for every language.


nicomp profile image

nicomp 6 years ago from Ohio, USA Author

@dusanotes: Thank you for your kind words.


Bishnu 5 years ago

Great tutorial, really helped me. I appreciate u...

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working