ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

NetBeans IDE and C++

Updated on December 28, 2009

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
working

This website uses cookies

As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://corp.maven.io/privacy-policy

Show Details
Necessary
HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
LoginThis is necessary to sign in to the HubPages Service.
Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
AkismetThis is used to detect comment spam. (Privacy Policy)
HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
Features
Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
MavenThis supports the Maven widget and search functionality. (Privacy Policy)
Marketing
Google AdSenseThis is an ad network. (Privacy Policy)
Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
Index ExchangeThis is an ad network. (Privacy Policy)
SovrnThis is an ad network. (Privacy Policy)
Facebook AdsThis is an ad network. (Privacy Policy)
Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
AppNexusThis is an ad network. (Privacy Policy)
OpenxThis is an ad network. (Privacy Policy)
Rubicon ProjectThis is an ad network. (Privacy Policy)
TripleLiftThis is an ad network. (Privacy Policy)
Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
Statistics
Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
ClickscoThis is a data management platform studying reader behavior (Privacy Policy)