Sunday, 28 July 2013

GCC Compilers For Windows (Compile Your Code/Exploits Using Windows CMD)


GCC can be installed in windows environment using following two methods.
  • Cygwin
  • MinGW /MinGW Drived Third Party Tools

Cygwin:

If you will install it using Cygwin, then it will install a terminal of Cygwin where you can use your GCC compiler and other linux environment stuff. Cygwin is available in a standalone installer which can be downloaded and installed easily from the following link.
Download and installation instruction are available on the very same same download link.

Download Link: http://cygwin.com/install.html

Note: GCC installed through Cygwin will be available in Cygwin terminal only.You can't use it in Windows CMD environment.If you want to install it for Windows CMD then try MinGW.

 MinGW:

 GCC for Windows is provided by MinGW currently. MinGW provides only a 32-bit and 64-bit  compilers in two different projects.
 There are some third party compiler suites are available too which have both of these projects available in them.
TDM-GCC is one of those famous third party tool suites.It combines the most recent stable release of the GCC toolset with the free and open-source MinGW or MinGW-w64 runtime APIs to create a LIBRE alternative to Microsoft's compiler and platform SDK.
It can create 32-bit OR 64-bit binaries, for any version of Windows since Windows 95.
It comes with an easy-to-use single-file installer that creates a working installation with just a few clicks, and can automatically update that installation when new packages become available.

Download Link for MinGW(32-bit): http://sourceforge.net/projects/mingw/
Download Link for MinGW-W64(64-bit): http://sourceforge.net/projects/mingw-w64
Download Link for MinGW-Builds: http://sourceforge.net/projects/mingwbuilds/
Download Link for TDM-GCC: http://tdm-gcc.tdragon.net/download

I am currently using TDM-GCC compiler suite. So, i would you to use it too.Download and install it.Now testing phase comes :)
Lets create a simple C file and test it.
Open your notepad and copy paste the following C code and save this file as test.c
#include "stdio.h"
main(){
printf("this is a test file");
}
 Now run your cmd and compile this code using following GCC command and check either its working or not.
gcc test.c -o test
 I got the following output :) .Cheers its working perfectly.