简体   繁体   English

在路径:windows中找不到Eclipse g ++

[英]Eclipse g++ not found in path: windows

I am attempting to setup SDL2 for C++ with Eclipse on Windows 7. 我试图在Windows 7上使用Eclipse为C ++设置SDL2。

In order to do so, I am following the tutorial in this link , which states that I must first install MinGW. 为了做到这一点,我正在按照此链接中的教程进行操作, 该链接指出我必须首先安装MinGW。 So I follow the link provided in order to setup MinGW. 所以我按照提供的链接来设置MinGW。 I follow all the steps without issue. 我毫无问题地遵循所有步骤。 I then open Eclipse and attempt to build a simple hello world program: 然后我打开Eclipse并尝试构建一个简单的hello world程序:

#include <iostream>

using namespace std;

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

To my surprise, this code doesn't build, with 6 errors. 令我惊讶的是,这个代码没有构建,有6个错误。

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 在PATH中找不到程序“g ++”
  2. Program "gcc" not found in PATH 在PATH中找不到程序“gcc”

Here is a screenshot. 这是一个截图。 构建错误

However, my path does contain "C:\\mingw\\bin". 但是,我的路径确实包含“C:\\ mingw \\ bin”。 I have also tried changing this to "C:\\mingw". 我也尝试将其更改为“C:\\ mingw”。 Looking inside "C:\\mingw\\bin", I find gcc and g++: 在里面看“C:\\ mingw \\ bin”,我找到了gcc和g ++: mingw \\ bin中的gcc和g ++

In addition, compiling a test program using the command line (g++ Test.cpp -o Test) works just fine, as does "g++ -v". 此外,使用命令行(g ++ Test.cpp -o Test)编译测试程序的工作正常,“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. 我一直在网上搜索几个小时,似乎无法找到答案为什么Eclipse似乎无法用MinGW编译任何东西。 Questions I have looked at on SO (which haven't been able to fix my issue) include: 我在SO上看到的问题(无法解决我的问题)包括:

  1. Eclipse mingw binary not found 找不到Eclipse mingw二进制文件
  2. Eclipse not finding c std libraries Eclipse没有找到c std库
  3. g++ not found in path 在路径中找不到g ++
  4. Eclipse C++ : "Program g++ not found in PATH" Eclipse C ++:“在PATH中找不到程序g ++”
  5. Program g++ not found in path 在路径中找不到程序g ++
  6. Program g++ not found in path C++ [duplicate] 在路径C ++中找不到程序g ++ [重复]
  7. Eclipse CDT (Juno) in Win7: Cannot find g++ in PATH, iostream unresolved and other fun stuff Win7中的Eclipse CDT(Juno):在PATH中找不到g ++,iostream未解析和其他有趣的东西

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 . 附加信息:窗口>首选项> C / C ++>构建>设置>“CDT GCC内置编译器设置MinGW [共享]”: 在此系统上未检测到工具链MinGW GCC

I have also reinstalled Eclipse to no avail. 我也重新安装了Eclipse无济于事。

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. 请根据需要提供更多信息。

You need to set the environment for the c/c++ builder. 您需要为c / c ++构建器设置环境。

  • First you need to install the GNU tool-chain, you can choose either MinGW or Cygwin. 首先,您需要安装GNU工具链,您可以选择MinGW或Cygwin。 You can see the steps here . 你可以在这里看到这些步骤。 I used MinGW. 我用过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: 转到Window-> Preferences-> C / C ++ - > Build-> Environment并添加一个新变量,将其命名为任何你想要的名称,例如命名为“MINGW”,现在粘贴MinGW的二进制目录,默认为C: \\ MinGW \\ bin ,你应该有这样的东西:

在此输入图像描述

  • Now when you create a new project you just have to select the MinGW tool-chain: 现在,当您创建一个新项目时,您只需选择MinGW工具链:

在此输入图像描述

Hope that helps. 希望有所帮助。

It appears as though I have fixed the problem for the moment. 好像我现在已经解决了这个问题。

In case others encounter the same issue: Project > Properties > C/C++ Build > Settings > MinGW C++ Linker > Command changed from "g++" to "C:\\mingw\\bin\\g++". 如果其他人遇到相同的问题:项目>属性> C / C ++生成>设置> MinGW C ++链接器>命令从“g ++”更改为“C:\\ mingw \\ bin \\ g ++”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM