Eclipse C++:“在路径中找不到程序“g++”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11703432/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse C++ : "Program "g++" not found in PATH"
提问by LCJ
I have gpp installed in my Windows 7 (32 bit) as shown in the picture.
如图所示,我在 Windows 7(32 位)中安装了 gpp。
PATH variable gas g++
PATH 变量气体 g++
"%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\cygnus\cygwin-b20\H-i586-cygwin32\bin\g++"
Still eclipse shows the error:
仍然eclipse显示错误:
"Program "g++" not found in PATH".
“在 PATH 中找不到程序“g++”。
How can this be resolved?
如何解决这个问题?
回答by user1558573
Today I have bumped into this problem and solved it in the following way. I pressed "Reset defaults" button everywhere I could find it in Eclipse settings (for example, Preferences/C++/Build/Settings/Discovery). After that the error disappeared and the code compiled successfully.
今天碰到了这个问题,按照下面的方法解决了。我在 Eclipse 设置(例如,首选项/C++/Build/Settings/Discovery)中可以找到它的任何地方都按下了“重置默认值”按钮。之后错误消失并且代码编译成功。
回答by Shashank Saxena
This is how I got rid of it:
这就是我摆脱它的方式:
- Install the MinGW.
- Select all files in the Basic Setup and select apply the changes.
- Select new C++ Project You will be able to see "MinGW GCC" in the toolchain section select the same and create project.
- 安装 MinGW。
- 选择基本设置中的所有文件,然后选择应用更改。
- 选择新的 C++ 项目您将能够在工具链部分看到“MinGW GCC”,选择相同的并创建项目。
回答by Peter_pk
You need a gcc
, g++
compiler toolchain (on your windows machine) for the eclipse which you have manually downloaded,
One of the options can be done implicit via cygwin
installation(by selecting proper development packages for gcc
, g++
) and then add the location of the compiled gcc
,g++
package like C:\cygwin\etc\alternatives
to the PATH
variable for windows environment.
您需要一个gcc
,g++
编译器工具链(在您的 Windows 机器上)用于手动下载的 eclipse,其中一个选项可以通过cygwin
安装隐式完成(通过为gcc
,选择适当的开发包g++
),然后添加已编译的gcc
,g++
包的位置喜欢windows 环境C:\cygwin\etc\alternatives
的PATH
变量。
After this open eclipse and go to Project->properties->C/C++ Tool Chain Editor
and add replace default GNU C++ compiler
and GNU C Compiler
with Cygwin C++ compiler
and Cygwin C compiler
and rebuild the project. The errors related to gcc, g++ PATH not found
will now be gone.
这种开放时期以后,去Project->properties->C/C++ Tool Chain Editor
添加替换默认GNU C++ compiler
,并GNU C Compiler
与Cygwin C++ compiler
和Cygwin C compiler
重建项目。相关的错误gcc, g++ PATH not found
现在将消失。
回答by ouah
You need:
你需要:
C:\cygnus\cygwin-b20\H-i586-cygwin32\bin
in the PATH
.
在PATH
.
and not
并不是
C:\cygnus\cygwin-b20\H-i586-cygwin32\bin\g++
as you wrote.
正如你所写。
回答by WorldFS
I got the same problem with mingw-64 (x86_64-4.9.1-release-posix-seh-rt_v3-rev1), Eclipse Luna 4.4.1 and CDT 8.5.0.201409172108, using Windows 7.
我在使用 Windows 7 的 mingw-64 (x86_64-4.9.1-release-posix-seh-rt_v3-rev1)、Eclipse Luna 4.4.1 和 CDT 8.5.0.201409172108 上遇到了同样的问题。
I solved this problem by putting the following two environment variables under
我通过将以下两个环境变量放在下面解决了这个问题
Window -> Preferences -> C/C++ -> Build-> Environment
窗口 -> 首选项 -> C/C++ -> 构建 -> 环境
- name: MINGW_HOME value: (mingw installation directory without "\bin")
- name: MSYS_HOME value: (msys installation directory without "\bin")
- 名称:MINGW_HOME 值:(mingw 安装目录不带“\bin”)
- 名称:MSYS_HOME 值:(msys 安装目录不带“\bin”)
You can check
你可以检查
Window -> Preferences -> C/C++ -> Build -> Settings -> Discovery -> CDT GCC Built-in Compiler Settings MinGW [ Shared ]
Window -> Preferences -> C/C++ -> Build -> Settings -> Discovery -> CDT GCC Built-in Compiler Settings MinGW [共享]
, if it doesn't complain "Toolchain MinGW GCC is not detected on this system" then you're all set.
,如果它没有抱怨“在此系统上未检测到 Toolchain MinGW GCC”,那么您就大功告成了。
回答by theten
I had the same problem, the only solution that worked for me was this:
我遇到了同样的问题,唯一对我有用的解决方案是:
- Open command-line and check whether "g++" actually executes the compiler
- If (1) works, uncheck Project->Build automatically in Eclipse
- Clean project
- Build project
- 打开命令行并检查“g++”是否实际执行编译器
- 如果 (1) 有效,请在 Eclipse 中取消选中 Project->Build automatic
- 清洁工程
- 构建项目
回答by huahsin68
The PATH
is locate at Project Properties > C/C++ Build > Environment (see screenshot below).
的PATH
是定位在项目属性> C / C ++编译>环境(参见下图)。
For your reference, I am using MinGW, I got the same error before I got the MSYS install. Later I found out that I also need MSYS to be install because the make.exe
wasn't come with MinGW. (I don't this error was cause be MSYS.)
供您参考,我正在使用 MinGW,在安装 MSYS 之前我遇到了同样的错误。后来我发现我还需要安装 MSYS,因为它make.exe
没有随 MinGW 一起提供。(我不认为这个错误是 MSYS 的原因。)
After MSYS is installed, add MSYS and MinGW path into environment variable, restart Eclipse. Remember to rebuild your project in order to rectify the error. If error still persist after restart, recreate the workspace. At least this has solved the problem on my site, hopes this help on you too.
MSYS安装完成后,将MSYS和MinGW路径加入环境变量中,重启Eclipse。请记住重建您的项目以纠正错误。如果重新启动后错误仍然存在,请重新创建工作区。至少这已经解决了我网站上的问题,希望这对你也有帮助。
Good luck!
祝你好运!
回答by M. Khaled
I had the same problem: Eclipse couldn't find (g++) and (gcc) in PATH even they were accessible from command-line. I was also sure they are pointed by PATH correctly.
我遇到了同样的问题:Eclipse 在 PATH 中找不到 (g++) 和 (gcc),即使它们可以从命令行访问。我也确信它们是由 PATH 正确指向的。
I have just deleted the (.metadata) folder from Eclipse's Workspace as a mean to reset it and this worked for me.
我刚刚从 Eclipse 的工作区中删除了 (.metadata) 文件夹作为重置它的手段,这对我有用。
回答by JoR
I had a similar problem. The error is raised, but the code is compiled and linked. The error was caused by the Error Parser using a different configuration than the one that is compiled.
我有一个类似的问题。引发错误,但代码已编译并链接。该错误是由错误解析器使用与编译的配置不同的配置引起的。
The error parser configuration was only valid for the Linux configuration of my software. My active configuration was set for MinGW and Windows.
错误解析器配置仅对我的软件的 Linux 配置有效。我的活动配置是为 MinGW 和 Windows 设置的。
Solution:
解决方案:
- In Elipse under Windows->Preferences->C/C++->Indexerset Build Configuration for the indexer to Use active build configuration.
- Clean and rebuild, otherwise the old errors will remain visible
- 在Windows->Preferences->C/C++->Indexer下的 Elipse 中,将索引器的 Build Configuration 设置为Use active build configuration。
- 清理并重建,否则旧错误将保持可见
回答by Akash5288
I had similar problem and I solved it by:
我有类似的问题,我解决了它:
Installing g++ The GNU C++ compiler using Ubuntu Software Center
使用 Ubuntu 软件中心安装 g++ GNU C++ 编译器
Changing in: Window -> Preferences -> C/C++ -> Build -> Settings -> Discovery -> CDT GCC Build in Complier Settings [Shared] from: ${COMMAND} -E -P -v -dD "${INPUTS}" to: /usr/bin/${COMMAND} -E -P -v -dD "${INPUTS}"
在:窗口 -> 首选项 -> C/C++ -> 构建 -> 设置 -> 发现 -> CDT GCC 编译器设置 [共享] 中构建来自:${COMMAND} -E -P -v -dD "${INPUTS }" 到: /usr/bin/${COMMAND} -E -P -v -dD "${INPUTS}"
I hope it helps.
我希望它有帮助。