How to compile and run C++ with MinGW using Eclipse and CDT?

After browsing many threads and articles I've found a solution. Solution tested on Windows 10 x64 on Eclipse Neon.3 Release (4.6.3) with C/C++ Development Tools 9.2.1.201704050430 and MinGW

System configuration

  1. Download MinGW. Any distro might work. I used the distro recommended on http://isocpp.org/
  2. Extract archive into C:\MinGW (actually to C:\, because archive contains folder MinGW)
  3. RMB on This PC -> Properties -> Additional system settings -> Tab Advanced-> Button Environment variables
  4. On second table System variables click New. Name variable MINGW_HOME and set path to MinGW install folder C:\MinGW and then OK
  5. Find variable Path in table and choose Edit
  6. In new window click New and type %MINGW_HOME%\bin\
  7. Confirm actions by clickig OK in opened windows
  8. You can check availability of new tools by typing in command line g++ --version You should see something like

g++ (GCC) 6.3.0 Copyright (C) 2016 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Eclipse CDT configuration

  1. Install Eclipse with CDT or just add CDT to existing Eclipse installation
  2. Go to the folder with installed MinGW (C:\MinGW\bin\). Make a copy of file gcc.exe (DO NOT RENAME original file!)
  3. Rename copied filed to mingw32-gcc.exe (You should have both files gcc.exe and mingw32-gcc.exe in \MinGW\bin\)
  4. Open Eclipse and select C\C++ perspective
  5. Go to Window -> Preferences -> C\C++ -> Build -> Environment
  6. Click Add and type PATH as name and click on Variables and select Path. Confirm with Ok.
  7. Select new variable PATH by clicking Select and then Ok.
  8. Restart Eclipse

Now you should be able to compile Hello World program. Just select New -> C++ Project. Here you should see available MinGW as Toolchain


Does Setting up Eclipse CDT on Windows, Linux/Unix, Mac OS X work for you?