Friday 17 January 2014

Running C with GCC compiler in windows with Netbeans IDE

This pretty simple layman question, but still some tricky to install GCC compiler in windows, making functional with C or any thing else C++, Fortan etc.

Recently, i need to run program for OpenMP (For parallel programming  ), parrallel thread executed in order to complete my course syallabus as  a part of Advance computer architecture. So little time, it took to initially figure out how to install it, & work for it with GCC. Prior to it, it was never been with GCC, all we have is turbo C++ Blue screen, in college time. But now that was obsolete, say working to as similar as in early 90's. So need change there.  So here it goes.

Installing on window there is: MinGw( www.mingw.org/)  compiler system that seems fine. It give you the windows installation manager
package from where you can install all the required package one by one exactly as similar as linux way.



Download and Run MinGw installation manager.
We need to install following packages as mandatory for C/C++ .
1) MinGw-Developer tool
2) mingGW32-base [This is required for C]
3) mingGwGcc-G++ [This is for C++]4) msys-base  [It include core basic utility functions]


After installation of all those package, 
Create a new project in NetBeans
Select tab C/C++ Applications 


The general package structure will be created. 
Now you have some tricky task. Those are setting environmental variable that is [Path] variable for MinGw and msys in your 
windows maching (Right Click My Computer-->Properties->Advanced Properties-->Environment Variable)

You need to set the path variable upto the bin directory. For ex : If your MinGw is installed as C:\MinGw then
path will be C:\MinGW\bin
similarly for mySys it would be C:\MinGW\msys\1.0\bin    
Note that place semicolon(;)  before and after of these variable entries in path variable .

Next you need to set configuration in you netbeans. For that. 
Go to Tools -->Options-->C/C++ tab

There most probably, [Make command] tab will be not mentioned explicitly, you need to mention it ,
browse the button and select C:\MinGW\msys\1.0\bin\make.exe file of MySys. 

Check all associated variable as well , if they are set correctly. 
Finally build the project , if it is build successfully, Congratulations.. !! 
You are done. ..









Cheers.. !!
Happy Learning. !!!

No comments:

Post a Comment