Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse g++ not found in path: windows

I am attempting to setup SDL2 for C++ with Eclipse on Windows 7.

In order to do so, I am following the tutorial in this link, which states that I must first install MinGW. So I follow the link provided in order to setup MinGW. I follow all the steps without issue. I then open Eclipse and attempt to build a simple hello world program:

#include <iostream>

using namespace std;

int main() {
    cout << "Hello World!" << endl;
    return 0;
}

To my surprise, this code doesn't build, with 6 errors.

I then proceed to simplify the program further:

int main()
{
    return 0;
}

This also does not compile. There are two errors:

  1. Program "g++" not found in PATH
  2. Program "gcc" not found in PATH

Here is a screenshot. build errors

However, my path does contain "C:\mingw\bin". I have also tried changing this to "C:\mingw". Looking inside "C:\mingw\bin", I find gcc and g++:gcc and g++ in mingw\bin

In addition, compiling a test program using the command line (g++ Test.cpp -o Test) works just fine, as does "g++ -v".

I have been searching the web for hours, and can't seem to find an answer as to why Eclipse can't seem to compile anything with MinGW. Questions I have looked at on SO (which haven't been able to fix my issue) include:

  1. Eclipse mingw binary not found
  2. Eclipse not finding c std libraries
  3. g++ not found in path
  4. Eclipse C++ : "Program g++ not found in PATH"
  5. Program g++ not found in path
  6. Program g++ not found in path C++ [duplicate]
  7. Eclipse CDT (Juno) in Win7: Cannot find g++ in PATH, iostream unresolved and other fun stuff

Additional info: Window > Preferences > C/C++ > Build > Settings > "CDT GCC Built-in Complier Settings MinGW [Shared]" : Toolchain MinGW GCC is not detected on this system.

I have also reinstalled Eclipse to no avail.

I realize that this may be a duplicate question of some that I have linked, but the information in previous questions have not been able to fix my problem, and I fear that adding a comment to an old question may not result in an answer.

Please request additional information as needed.

like image 654
Matt Martin Avatar asked Aug 10 '15 04:08

Matt Martin


1 Answers

You need to set the environment for the c/c++ builder.

  • First you need to install the GNU tool-chain, you can choose either MinGW or Cygwin. You can see the steps here. I used MinGW.
  • Go to Window->Preferences->C/C++->Build->Environment and add a new variable, name it whatever you want for example a named it "MINGW", now paste the binaries directory of MinGW which is by default C:\MinGW\bin, you should have something like this:

enter image description here

  • Now when you create a new project you just have to select the MinGW tool-chain:

enter image description here

Hope that helps.

like image 65
Jhossep Augusto Popayán Avila Avatar answered Sep 21 '22 00:09

Jhossep Augusto Popayán Avila