program g++ not found in path

2019-08-29 01:57发布

问题:

I am using Eclipse for a C project. I created a new Project by going to New->C project->Executable->Empty Project, Linux gcc toolchain.

When I add a new .c file, I get "program 'g++' not found in path". How do I get rid of this? I'm not even using C++.

回答1:

I had similar problem and it is solved by

  1. Installing g++ The GNU C++ complier using ubuntu software centre and

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



回答2:

For posterity I'm going to post my own solution to this problem. None of the answers above or on related StackOverflow questions helped; most referred to menu entries that didn't exist, and the ones I could try did nothing. I searched other sites as well; there were about 6 different answers repeated many times, and none helped.

Short answer: I blew away the Eclipse install and replaced it. Then it worked. For me at least it wasn't a project or configuration option (at least not one I could get to from the GUI); something in the Eclipse program folder had gotten tweaked and only a new install could repair the problem.

I'm doing Android development using the "ADT" (Android Developer Tools) build of Eclipse. I did something to the configuration that made it start giving the above error (actually two errors, for gcc and g++ both). And I tried plenty of potential solutions (in addition to my own searching for options that might help) with no success.

Thing is, I didn't NEED gcc or g++ in the path. I'm doing Android development, and while both are used in the build process, I'm not using Eclipse to do the builds; I use the Android build system. And the C/C++ Build/Discovery options didn't even give me an option for setting paths for gcc or g++. Other answers I found elsewhere referenced menu entries that don't exist, and most seemed to be about helping people to use the normal C/C++ build within Eclipse, which I didn't need to do.

So I used this opportunity to download the latest ADT package from Google, and then I ran the new one, importing the existing project into a new workspace (just in case the old workspace was corrupted or otherwise part of the problem). No more annoying gcc/g++ error.



回答3:

I got the same error while I was using "Eclipse IDE for C/C++ Developers."

Install Eclipse from Ubuntu Software Center and then download and install Eclipse CDT.

To install CDT, open Eclipse -> Help -> Install New Software -> Add -> Archieve... Then give CDT path to there. That's all



回答4:

I was able to fix the problem by selecting

project(right click in Project Explorer on your project)->properties->Tool Chain Editor

and switching the Current Toolchain: to Android GCC and Current Buolder: to Android Builder



标签: c eclipse g++