tecnico conferenza

« PreviousNext »

Using NetBeans for C/C++ Development

18 July 2006

NetBeans is a popular open source IDE used primarily for Java development. Recently NetBeans added support for developing C/C++ applications. Let’s see how easy it is to setup NetBeans for C/C++ development. Specifically I’m referring to NetBeans C/C++ Developer Pack.

Let’s install NetBeans and all prerequisites on Gentoo 2005.1 GNU/Linux System. It should be the same for non-Gentoo GNU/Linux distributions.

First download J2SE Development Kit 5.0 Update 7 from http://java.sun.com/javase/downloads/index.jsp. The binary should be of the name jdk-1_5_0_07-linux-i586.bin. Once the binary is downloaded change its mode to executable.

#chmod +x jdk-1_5_0_07-linux-i586.bin

Now execute the binary.

#./jdk-1_5_0_07-linux-i586.bin

Once JDK 1.5 Update 7 has been installed successfully, its time to download and Install NetBeans IDE 5.5 Beta(NetBeans IDE 5.5 Beta Installer) from http://www.netbeans.info/downloads/download.php?type=5.5b
Once it is downloaded change the binary to executable

#chmod +x netbeans-5_5-beta-linux.bin

Now execute the binary

#./netbeans-5_5-beta-linux.bin

A widget will pop-up. Perform these steps as widget goes on to asking questions

i. Press Next
ii. Accept the agreeement and press Next
iii.Choose a directory to install NetBeans and press Next
iv.Select the jdk installed and press Next
v. Press Next
vi Press Finish

As NetBeans has been installed, now we’ll install the NeBeans C/C++ Developer Pack

Download NetBeans C/C++ Developer Pack (NetBeans C/C++ Pack 5.5 EA Installer) from http://www.netbeans.info/downloads/download.php?type=5.5b After downloading, change the permissions of the binary to executable.

#chmod +x cnd-060615-linux.bin

Now execute the binary

#./cnd-060615-linux.bin

A widget will pop-up asking for your preferences.Perform the following steps as the questions come up

i. Press Next
ii. Accept the agreement and press Next
iii.Select the NetBeans Home Directory and press Next
iv.Press Next
v. Press Finish

Now it’s time to write a simple program using our newly installed NetBeans IDE.

Launch NetBeans 5.5 Beta by clicking the Icon on the Desktop
nb_main_window.jpg

Select File->New Project

A New Project Dialog Widget appears.
nb_file_project.jpg

Choose C/C++ Development from Categories, C/C++ Application from Projects and press Next

Change the Project Name to HelloWorld and press Finish
nb_new_ccpp.jpg

Now in the Projects pane, right click Source Files and select New->File/Folder
nb_new_file_fol.jpg

Now in the New File Dialog Box, from Categories, choose C++ Files, from the File Types choose Main C++ File and press Next

nb_new_cpp.jpg

Change the File Name to hello and press Finish

nb_main_cpp.jpg

Now a main function will be generated for you in hello.cc file.

nb_prog.jpg

Make sure the source code looks like this

#include <stdlib.h>
#include <stdio.h>
int main(int argc, char** argv) {
printf(”Hello,World\n”);
return (EXIT_SUCCESS);

}

Now Select Build->Build Main Project.
“Build Successful” message will be displayed.

nb_build.jpg

Now select Run->Run Main Project

“Hello, World” message will be displayed.

nb_run.jpg

We’ve successfully compiled and executed a simple C++ program using NetBeans IDE. This should get us started in using NetBeans as C/C++ IDE while developing C/C++ applications.

Posted in Programming | Trackback | del.icio.us | Top Of Page

No comments yet

Leave a Reply