Sunday, 14 September 2008

C and C++ programming - Configuring NetBeans (C/C++ support) (Updated to support 6.7.1)

norder to configure CYGWIN (C, C++ compiler) with NetBeans you need to do the following...

Phase 1: Installation
1. Install NetBeans from by clicking on "Download NetBeans IDE"

You need to install even install JDK which will be informed to you while you install NetBeans. Hence select the All-Download option in the website. Size : 219 MB...

2. Select C, C++ from the given options...
3. After Installing Successfully
4. You need to now install a C,C++ compiler.

Note: Have your compiler installed in "C:" drive.

5. Cygwin is a very good GCC compiler which can be downloaded from
6. Run the setup file and it asks you an internet connection. Wifi users of SASTRA University may specify Use proxy option and enter 8080 as usual.
7. You need to now select the package.
8. This is generally very complicated but can be understood of we put some logic.
9. At a minimum, select gcc-core: C compiler, gcc-g++: C++ compiler, gdb: The GNU Debugger, and make: the GNU version of the 'make' utility.
10. Now proceed to install.

Phase II : Testing your compiler..
1. Inorder to check that you've installed your cygwin properly, you need to do certain things.
2. Check if your destination folder contains all the required files of cygwin.
3. Check if your start menu > programs contains a folder named cygwin.
4. This means that you've installed it properly.
5. Now inorder to verify some more go to cygwin bash shell found in the cygwin folder of Start menu > programs.
6. Type cygcheck -c cygwin
7. also these gcc --version
g++ --version
make --version
gdb --version
8. Once you get them all right, you can feel proud that you've done 97.5% of the job.

Phase III : Configuring cygwin with Netbeans.
1. Goto control panel > System or My Computer Icon right click > properties.
2. Choose Advanced tab.
3. Click on Environment Variables.
4. In system variables' frame choose "path" and click "edit" button.
5. Now in the variable value textbox give the path of your cygwin/bin directory. (i.e. probably c:\cygwin\bin)
6. Click OK
7. Congratulations. You have taken a great step towards your better programming.

Now creating your first Cpp program... (Hello World.cpp)

1. Start your NetBeans IDE.
2. Goto File > New Project.
3. In Categories Pane select C/C++
4. In Projects pane select C/C++ Application
5. Click Next.
6. Enter your Project Name. ("Helloworld" here)
7. Choose your Project Location (if at all...)
8. Click on Finish.
9. Now you can see the Projects Tab of your right side containing lots of folders such as Header Files, Source Files, Resource Files, Important Files.
10. Now Right Click on Source Files and Choose...
Empty C++ file...
11. Give it a name...
12. Type the code.
13. Goto Build (Can find it in the Menu Bar) and click on Compile.
14. Once you compile, click on the green arrow button for running the program or By Choosing Run > Run Main Project.
15. Congrats. You've done a splendid job...!!!

Thanks for configuring your NetBeans for C, C++ with me patiently...
if you have any queries about installing NetBeans and Cygwin or be it anything reg. these,
Please do not hesitate to contact me... (or) (or)

Please note that once your NetBeans is configured, your tools > C++ contains the following things according to your installation.

Update for Netbeans 6.7.1 :

Download Cygwin. Choose the Following by clicking on the arrow kind of buttons.

Choose Devel...

1. GCC 2. G++ 3. GDB 4. NASM 5. G77 6. Make

After this, allow Cygwin to install the downloaded components.

Now open NetBeans 6.7.1 and Create a C/C++ project. Now, goto Tools and C/C++.

Click on add button and specify the location of Cygwin/bin directory. Its mostly in C drive.

Now, the cygwin will automatically be selected by Netbeans.

All you got to do now is delete the project and create a new one.! Things will work fine then..!


Ely said...

This is a good start, but incomplete. My NetBeans 6.5 configuration had no idea where the compiler executables and libraries were located. I had to manually add the exe location in the Tools>Options>C/C++>Build Tools configuration. I still haven't figured out where the library paths are that need to be included. I think they are in C:\cygwin\usr\include, but there are duplicate *.h files in other C:\cygwin paths. I also don't know if they should be included in the project properties or in the Tools>Libraries configuration.

Sanjeev Gopinath said...

This works well for previous version of NetBeans. Now Cygwin ppl started giving a few changes which makes it uncomfortable for executing the C++ programs in NetBeans. Sometimes as you said, we'll have to add the libraries manually by finding them out. Also if you closely note, GCC and G++ are downloaded as GCC-3 and GCC-4. And you know, yo'll have to rename these executables in your cygwin/bin directory as GCC and G++. Its a complex process only. You'll have to understand a few constraints and move on. If you really can't find where the files are located, try giving a search on "iostream" and this might give you a clear picture about the location of files.
You need not add any of those locations in your project options. Add them in your code assistance. For your sake, I'll add a pic that might help you sort things in a better manner.
Anyways Ely, it's a nice query. Please email me, comments might not be helpful in case if we need any interaction to solve the problem.

Akash said...

Sir i want to know about the C header files that are not included in Netbeans... one is Conio,h.......

Please tell me other header files... and how can we implement predefined functions which were in headerfiles of other compilers.......