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
- Download MinGW. Any distro might work. I used the distro recommended on http://isocpp.org/
- Extract archive into
C:\MinGW
(actually toC:\
, because archive contains folderMinGW
) - RMB on
This PC
->Properties
->Additional system settings
-> TabAdvanced
-> ButtonEnvironment variables
- On second table
System variables
clickNew
. Name variableMINGW_HOME
and set path to MinGW install folderC:\MinGW
and thenOK
- Find variable
Path
in table and chooseEdit
- In new window click
New
and type%MINGW_HOME%\bin\
- Confirm actions by clickig
OK
in opened windows - 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
- Install Eclipse with CDT or just add CDT to existing Eclipse installation
- Go to the folder with installed MinGW (
C:\MinGW\bin\
). Make a copy of filegcc.exe
(DO NOT RENAME original file!) - Rename copied filed to
mingw32-gcc.exe
(You should have both filesgcc.exe
andmingw32-gcc.exe
in\MinGW\bin\
) - Open Eclipse and select
C\C++
perspective - Go to
Window
->Preferences
->C\C++
->Build
->Environment
- Click
Add
and typePATH
as name and click onVariables
and selectPath
. Confirm withOk
. - Select new variable
PATH
by clickingSelect
and thenOk
. - 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?