Installing MinGW (gcc, g++) on Kali Linux to Compile Windows Code

Wednesday, March 5, 2014

It is possible to compile windows code natively in Backtrack and Kali using MinGW compiler and Wine. While MinGW comes already installed and configured for users in Backtrack, it does not in Kali.

Let's go over how to install and configure MinGW for Kali and how to use it to compile windows code, but first some quick definitions.

What is Wine?

Wine allows windows applications to be run on several platforms such as Linux, Mac OS X and more.

What is MinGW?

MinGW is a collection of windows development tools including compilers such as GCC and G++. Using both MiniGW and Wine it is possible to compile windows code thus creating a portable executable (pe) which can be later run with wine.

Installing MinGW on Kali Linux

As previously mentioned, MinGW does not come installed on Kali by default. Thus one does not have access to important tools and compilers such as gcc. Let's install and configure it.

  1. Download the MinGW installer from their sourceforge.
  2. Run the installer (mingw-get-setup.exe) with wine.

  3. Select the Install with GUI option.
  4. The MinGW installation manager should now be open. Select mingw32-base.

  5. Select Installation > Update Catalogue on the top left hand corner.

  6. Some missing DLLs will need to be downloaded, download them here
  7. Unzip them and move them to the wine drive_c/windows folder.

Excellent, we now have Mingw installed! You can confirm this by visiting the /root/.wine/drive_c/MinGW directory. You should also have gcc installed under /root/.wine/drive_c/MinGW/bin/gcc.exe.

Compiling Windows Code in Kali and Backtrack

With MinGW installed all we have to do now is use gcc to compile our c code. Below is an example of usage. The example below assumes the user is inside the /root/.wine/drive_c/MinGW/bin directory.

There we have it! Go Compile!


  1. Hi, your does not exist. Can you send your new link?

  2. there is no gcc.exe on bin folder, plz help

  3. How can I compile C++ source code
    I fallowed this tutorial and I am able to compile C programs using
    wine gcc.exe source.c -o executable.exe
    there is no g++.exe in the ~/.wine/drive_c/MinGW/bin/ dir