Reputation: 129075
I would like to do some C++ development on Windows using Eclipse and the CDT plugin. I use Eclipse Helios SR1 and have installed the CDT plugin. I have also installed MinGW and now I wrote a simple "Hello World" in Eclipse.
hello.cpp
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World" << endl;
return 0;
}
In Eclipse using the CDT plugin and the MinGW compiler. How can I compile my program? And how can I test run the program from within Eclipse?
Upvotes: 18
Views: 102406
Reputation: 61
Chocolatey is one package manager that allows mingw install with a single command using Windows Powershell.
choco install mingw --version=8.1.0
After the installation is done, add the below toolchain path to Eclipse->Window->Preferences-> Core Build ToolChains -> User Defined ToolChains.
C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin\gcc.exe
Restart eclipse. The MinGW toolchain should be available for use now in Eclipse.
Upvotes: 0
Reputation: 21
Just add MinGW
to System Path(System configuration part in AndriiL's post) is enough. The variable named PATH
with ${PATH}
as value will be added automatically in Window -> Preferences -> C\C++ -> Build -> Environment
and you can see MinGW GCC
as a toolchain option in project wizard. If no PATH variable presented, Eclipse CDT may not load the recent System Path changes in the OS(Click Select...
and choose Path variable
, the value may not contain MinGW path), just Exit Eclipse and open it again.
Upvotes: 0
Reputation: 89
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
C:\MinGW
(actually to C:\
, because archive contains folder MinGW
)This PC
-> Properties
-> Additional system settings
-> Tab Advanced
-> Button Environment variables
System variables
click New
. Name variable MINGW_HOME
and set path to MinGW install folder C:\MinGW
and then OK
Path
in table and choose Edit
New
and type %MINGW_HOME%\bin\
OK
in opened windowsg++ --version
You should see something likeg++ (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
C:\MinGW\bin\
). Make a copy of file gcc.exe
(DO NOT RENAME original file!)mingw32-gcc.exe
(You should have both files gcc.exe
and mingw32-gcc.exe
in \MinGW\bin\
)C\C++
perspectiveWindow
-> Preferences
-> C\C++
-> Build
-> Environment
Add
and type PATH
as name and click on Variables
and select Path
. Confirm with Ok
.PATH
by clicking Select
and then Ok
.Now you should be able to compile Hello World program. Just select New
-> C++ Project
. Here you should see available MinGW as Toolchain
Upvotes: 6
Reputation: 14481
Does Setting up Eclipse CDT on Windows, Linux/Unix, Mac OS X work for you?
Upvotes: 12