Monday, November 5, 2012

netbeans and c++


Netbeans IDE can be used to create C/C++ Applications. Netbeans running on Linux Platforms dont require any additional configuration if the compilers are already available in the Linux distribution. But to get it working in Windows, a Linux-like environment will be required. 
Cygwin is a Linux-like environment for Windows.
Here is a step by step guide to configure Cygwin with Netbeans in Windows.
Step 1: Installing Netbeans
  • Install JDK. The latest version can be downloaded here
  • Download and install Netbeans. The latest version is Netbeans IDE 6.5. The latest version can be downloaded from http://www.netbeans.org. Make sure you download the bundle that has all technologies.
  • Select C/C++ option while installing. ( It is better to select all the options )
Step 2: Installing Cygwin
  • Cygwin can be downloaded from http://www.cygwin.com
  • Run the setup file.
  • Install from internet. Specify C:\cygwin as the root directory.
  • In the Select Packages dialog box, select the packages required. gcc-coregcc-g++gdb, and makepackages are most important. These are the C core, C++ core, the GNU Debugger and the GNU version of ‘make’ utility. These packages will be under the ‘Devel’ category.
  • Complete the installation.
Step 3: Testing Cygwin
  • To test whether Cygwin was installed properly, try the following by opening the bash shell:
  • cygcheck -c cygwin
    gcc --version
    g++ --version
    make --version
    gdb --version
  • If the version details are displayed for all these commands, the installation of Cygwin has been successful.
Step 4: Setting PATH
  • Right click on My Computer and select Properties. Goto Advanced System Settings.
  • Click on Environment Variables.
  • In system variables’ frame choose “Path” and click “edit” button.
  • Now in the variable value textbox give the path of your cygwin/bin directory. (i.e., probably c:\cygwin\bin)
  • Click OK
The setup is done.
Now new C/C++ Projects can be started:
  • Open Netbeans IDE
  • CLick New Project –> C/C++ –> C/C++ Application
  • Choose a Project Name and Location. Then select ‘Finish’.
  • Right click on Source Files under the current Project in the Projects pane on the left side.
  • Select New –> Empty C++ File
  • Type in the C++ Program.
  • Now go to Run –> Run Main Project or press F6 to run the program.