In this post I will briefly cover the steps required to install the MinGW C compiler on a Linux system.
In order to achieve this, you will need a working version of wine, and you will need to be running your Linux system in GUI mode. Many Linux distributions will have wine available in their repositories, otherwise you can install it from here. I am performing the following steps on BackTrack 4 where wine comes installed by default.
Edit: ColForbin over at the BackTrack forums just kindly pointed out to me that MinGW comes installed by default on BackTrack 4 Final. I apparently missed this because I run BackTrack as a non root user (against the recommendations of the BackTrack Developers by the way), and MinGW is only installed under the root users home directory. So if you use BackTrack 4 Final, you only need to do the install of MinGW if you run as a non root user.
Start by download the latest version of the installer from here.
Now run the installer using wine.
user@bt4:~/Downloads$ wine MinGW-5.1.6.exeThe installer window will appear, as shown below.
Hit Next and follow the bouncing ball through the first few steps, accepting the defaults.
When asked where to install MinGW, install it to the path in the C:\ drive, which wine creates under your home folder in ~/.wine/drive_c/.
Progress through the installer, then wait while the components of MinGW are downloaded and installed.
Once the install is done hit Finish.
To actually use the compiler, run it as follows:
user@bt4:~$ wine ~/.wine/drive_c/MinGW/bin/gcc.exeTo compile a Windows c source file into an executable:
gcc.exe: no input files
user@bt4:~$ wine ~/.wine/drive_c/MinGW/bin/gcc.exe code.c -o code.exeFor programs that require the use of particular libraries, you can also use one of the following command line switches to gcc to compile a given program using the given library:
- -l[library name]
- -Xlinker [Full path to library file]
Use the wsock32 library:
Use the GDI32 library: