当前位置 : 首页 » 互动问答 » 正文

Eclipse C++ : "Program "g++" not found in PATH"

分类 : 互动问答 | 发布时间 : 2012-07-29 02:00:20 | 评论 : 20 | 浏览 : 189075 | 喜欢 : 35

I have gpp installed in my Windows 7 (32 bit) as shown in the picture.

enter image description here

PATH variable gas 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:

"Program "g++" not found in PATH".

How can this be resolved?

enter image description here

回答(20)

  • 1楼
  • 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.

  • 2楼
  • This is how i got rid of it.

    1. Install the MinGW.
    2. Select all files in the Basic Setup and select apply the changes.
    3. Select new C++ Project You will be able to see "MinGW GCC" in the toolchain section select the same and create project.
  • 3楼
  • 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.

    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.

  • 4楼
  • You need:

    C:\cygnus\cygwin-b20\H-i586-cygwin32\bin
    

    in the PATH.

    and not

    C:\cygnus\cygwin-b20\H-i586-cygwin32\bin\g++
    

    as you wrote.

  • 5楼
  • I had the same problem, the only solution that worked for me was this:

    1. Open command-line and check whether "g++" actually executes the compiler
    2. If (1) works, uncheck Project->Build automatically in Eclipse
    3. Clean project
    4. Build project
  • 6楼
  • 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.

    I solved this problem by putting the following two environment variables under

    Window -> Preferences -> C/C++ -> Build-> Environment

    • name: MINGW_HOME value: (mingw installation directory without "\bin")
    • name: MSYS_HOME value: (msys installation directory without "\bin")

    You can check

    Window -> Preferences -> C/C++ -> Build -> Settings -> Discovery -> CDT GCC Built-in Compiler Settings MinGW [ Shared ]

    , if it doesn't complain "Toolchain MinGW GCC is not detected on this system" then you're all set.

  • 7楼
  • 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.

    I have just deleted the (.metadata) folder from Eclipse's Workspace as a mean to reset it and this worked for me.

  • 8楼
  • The PATH is locate at Project Properties > C/C++ Build > Environment (see screenshot below).

    enter image description here

    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.)

    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.

    Good luck!

  • 9楼
  • 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.

    Solution:

    • In Elipse under Windows->Preferences->C/C++->Indexer set Build Configuration for the indexer to Use active build configuration.
    • Clean and rebuild, otherwise the old errors will remain visible
  • 10楼
  • Maybe it has nothing to do here, but it could be useful for someone.
    I installed jdk on: D:\Program Files\Java\jdk1.7.0_06\bin
    So I added it to %PATH% variable and checked it on cmd and everything was ok, but Eclipse kept showing me that error.
    I used quotation marks on %PATH% so it reads something like:

    %SYSTEMROOT%\System32;"D:\Program Files\Java\jdk1.7.0_06\bin"
    

    and problem solved.

  • 11楼
  • I had similar problem and I solved it by:

    Installing g++ The GNU C++ compiler using Ubuntu Software Center

    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}"

    I hope it helps.

  • 12楼
  • I had the same problem in Sublime..

    1. Right click on my computer
    2. Advanced system settings
    3. Environment variables
    4. in system variables, change path to location of '...\MinGW\bin'

    Example: D:\work\sublime\MinGW\bin

  • 13楼
  • i think cgywin might not work for you as you can only compile your code in Win7 if you fire up the command prompt; you need to use MinGW compiler toolset instead. After you have install your compiler, go to Properties->C/C++ Build->Tool Chain Editor -> Change your current toolchain to MinGW GCC.

  • 14楼
  • 使用适用于OS RTEMS的GR712RC安装的Gaisler工具,所有提示都不适合我。 我正在使用Eclipse Kepler。

    简单的方法是创建一个copy of sparc-rtems-gcc.exe to gcc.exe, and sparc-rtems -g ++。exe to g++.exe, in the C:\ opt \ rtems-4.10-mingw \ BIN directory.

  • 15楼
  • WINDOWS 7

    If there is anyone new reading this, make sure to simply try a clean install of mingw before any of this. It will save you sooooo much time if that is your problem.

    I opened up wingw installer, selected every program for removal, apply changes (under installation tab, upper left corner), closed out, went back in and installed every file (in "Basic Setup" section) availible. after that eclipse worked fine using "MinGW GCC" toolchain when starting a new C++ project.

    I hope this works for someone else. If not, I would do a reinstall of JDK (Java Developer's Kit) and ECLIPSE as well. I have a 64bit system but I could only get the 32bit versions of Eclipse and JDK to work together.

  • 16楼
  • In my case, I didnt mark for instalation the mingw32-gcc-g++ package in the installation manager, that's why eclipse didn't know it.

    Needed to go to the instalation manager, mark it (in basic setup tab) and update catalogue

  • 17楼
  • First Install MinGW or other C/C++ compiler as it's required by Eclipse C++.

    Use https://sourceforge.net/projects/mingw-w64/ as unbelievably the download.cnet.com's version has malware attached.

    Back to Eclipse.

    Now in all those path settings that the Eclipse Help manual talks about INSTEAD of typing the path, Select Variables and

    **MINGW_HOME** 
    

    and do so for all instances which would ask for the compiler's path.

    First would be to click Preferences of the whatever project and C/C++ General then Paths and Symbols and add the

    **MINGW_HOME** to those paths of for the compiler.
    

    Next simply add the home directory to the Build Variables under the C++/C Build

    Build Variables Screen Capture

  • 18楼
  • If you have your PATH setup and you can see g++ --version via the command line, then try to delete the project and create a new c++ project.

    So the reset defaults might work but I think it has to update the PATH if it wasn't added before.

  • 19楼
  • Had this problem on windows 10, eclipse Neon Release (4.6.0) and MSYS2 installed. Eclipse kept complaining that "Program 'g++' not found in PATH” and "Program 'gcc' not found in PATH”, yet it was compiling and running my C++ code. From the command prompt, I could run g++.

    Solution was to define the C++ Environmental variable for eclipse called 'PATH' to point to windows variable called 'path' also $(Path). Menus: Preferences>>C/C++>>Build>>Environment

    Looks like eclipse is case sensitive with the name of this environmental, while windows doesn't care about the case.

  • 20楼
  • The reason is that eclipse cannot find your gcc or g++ environment variable path.

    You might have tried to run c or c++ or fortran but eclipse cannot find out the compiler.

    So, add the path in your environment variable.

    1. Windows -> Search -environment variables -> click on environmental variables at bottom.

    2. Click on path ->edit -> new -> your variable path

    Path should be entire, for example:

    C:\Users\mahidhai\cygwin64\usr\sbin
    

    Make sure that the variable is permanently stored. It is not erased after you close the environment variables GUI.

    Sometimes you might find it difficult to add a path variable. Make sure windows is updated.

    Even if Windows is updated and you have problems, directly go to the registry and navigate to the below.

    HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
    

    Add your path here. Remove any unnecessary repetitions of path variables.

    Note: You need to add your path variables in system environment variables -path

相关阅读:

The Definitive C Book Guide and List

How to convert string to char array in C++?

Cannot run Eclipse; JVM terminated. Exit code=13

The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

How to remove unused imports from Eclipse

How does C compute sin() and other math functions?

Eclipse: All my projects disappeared from Project Explorer

Detecting EOF in C

Failed to load the JNI shared Library (JDK)

Can't start Eclipse - Java was started but returned exit code=13