Eclipse g ++ not found in path: windows

I am trying to configure SDL2 for C ++ with Eclipse on Windows 7.

To do this, I follow the manual in this link , which says that I must first install MinGW. Therefore, to configure MinGW, I follow the link. I follow all the steps without any problems. Then I open Eclipse and try to create a simple hello world program:

#include <iostream> using namespace std; int main() { cout << "Hello World!" << endl; return 0; } 

To my surprise, this code is not built with 6 errors.

Then I continue to simplify the program further:

 int main() { return 0; } 

It also does not compile. There are two errors:

  • Program "g ++" not found in PATH
  • Program "gcc" not found in PATH

Here is a screenshot. build errors

However, my path contains "C: \ mingw \ bin". I also tried changing this to "C: \ mingw". Looking in "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 working on the Internet for hours and cannot find an answer on why Eclipse cannot compile anything with MinGW. Questions that I looked at SO (which could not fix my problem) include:

Additional information: Window> Preferences> C / C ++> Build> Settings> "Settings of the built-in CDT GCC MinGW [Shared] commander": Toolchain MinGW GCC was not found in this system.

I also reinstalled Eclipse to no avail.

I understand that this may be a duplicate question about some of which I related, but the information in the previous questions could not fix my problem, and I am afraid that adding a comment to the old question may not lead to an answer.

Please request additional information as needed.

+4
source share
2 answers

You need to install the environment for the c / C ++ linker.

  • First you need to install the GNU toolchain, you can choose 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 the way you want, for example, its name is β€œMINGW”, now insert the MinGW binary directory, which defaults to C: \ MinGW \ bin , you should have something like this:

enter image description here

  • Now when you create a new project, you just need to select the MinGW toolchain:

enter image description here

Hope this helps.

+3
source

I seem to have fixed the problem for now.

In case others are faced with the same problem: Project> Properties> C / C ++ Build> Settings> MinGW C ++ Linker> Command changed from "g ++" to "C: \ mingw \ bin \ g ++".

0
source

All Articles