10
votes

I apologize beforehand for this noobish Q, but Im starting to learn C++, and have only used Java.

I have also searched here and elsewhere for a solution to this and followed all steps and still getting this error.

I will try to be as specific as I can to help you guys.

I have eclipse helios and wanted to code C++ using it, but I keep running into the "Launch failed. Binary Not found" error.

I installed the MingW C++ compiler using the "mingw-get-inst-20120426" file and selected the "C compiler, C++ compiler, MSYS Basic System, and MingW Developer Toolkit".

Then I went to eclipse > project > properties > C/C++ General > Paths and Symbols, then selected the GNU C++ in the Includes tab and added the "C:\MinGW\lib\gcc\mingw32\4.6.2\include\c++" path

I also went to C/C++ build > Environment and appended the "C:\MinGW\bin;C:\MinGW\msys\1.0\bin" to the PATH.

Then I created a Hello World C++ project, selecting the MingW GCC under Toolchains, and then build the project using the "hammer" icon.

However, once I ran the HelloWorld program it gets the "Launch failed. Binary Not Found" error.

Here is another error: g++ -IC:\MinGW\lib\gcc\mingw32\4.6.2\include\c++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\HelloWorld.o ..\src\HelloWorld.cpp Internal Builder: Cannot run program "g++": The system cannot find the file specified.

I also downloaded the CDT (C/C++ Development Tooling) and transferred the "features" and "plugins" folder to the eclipse folder.

Can someone please give me step-by-step on how to resolve this?

4
So you failed to place g++ on the path. There are several possible reasons why. Check the path; check the directory contents; make sure that the path takes effect when Eclipse tries to run g++. - Marko Topolnik
I'm not sure exactly how to do that?....Can you explain how? thanks - user1631224
Sorry, not the expert on CDT. You do mention configuring the PATH variable in C/C++ build > Environment, but I don't know if that's it. I can only say that this is the direction where you must search for your problem. The Launch Failed error is a consequence of failing to find the g++ compiler in the first place. - Marko Topolnik
After installing g++ did you add it to Environment variables? - Srijan
thanks Jesse, but I already tried that also, but when I run the code, it still says "Binary not found" and I also see in my code next to #include <iostream>, it says "Unresolved inclusion: <iostream>" - user1631224

4 Answers

21
votes

Firstly, in the following examples all drive-letters should be replaced with the relevant ones on your system. Not all of these steps are really necessary, but it works (and the more the merrier).

We start with the slightly simpler release config - we want to make it compile.

Go to Project -- Properties

Look if the include directories are correct and in place.

enter image description here

Go to Project -- Properties -- Run/Debug Settings -- NEW -- Main Tab

Set to Release and Browse to the Release folder of the project. If the exe file is not set type in its name.

Properties 1

Switch to Common Tab. Check Allocate Console and Launch in Background. Don't Run yet.

Properties 2

Go to Project -- Properties -- C/C++ Build -- Discovery Options

Tools -- GCC C++ Compiler

"Browse" to the mingw bin folder and select the g++.exe or copy mingw32-g++.exe to g++.exe

Note: The image points to mingw32-g++.exe please use g++.exe

Property 3

Right click on the project and look -- Build Configurations -- Set Active -- Release is checked.

Right click on the project -- Run As -- Run Configurations.

Under C/C++ Application select, the one which refers to the release version. Then click Run

If this works, I will show you how to set the Debug Properties. (more complicated)

9
votes

Nowadays (Eclipse Juno and newer), it is much simpler. You just need to:

  • Install MinGW (and including C++ compiler)
  • Add the paths "C:\minGW\bin" and "C:\minGW\msys\1.0\bin" (or wherever you installed MinGW to) to your Windows "Path" variable
  • Install Eclipse. If Eclise already is installed, restart it. it will recognize that MinGW is now available.
  • Create a New project: "C++ Project"
  • For every Project type in the following dialog, you should now be able to select the "MinGW GCC" toolchain
  • Happy coding
0
votes

g++ is installed as part of MinGW. If you are getting an error in Eclipse that it cannot find g++ then your path is most likely incorrect. From a command prompt you should be able to run:

g++ --version

and it should display the version of g++ in the MinGW/bin directory.

Eclipse uses this path to locate the include files and the compiler. Once you get the path correct restart Eclipse and the problems listed in your question should be resolved.