11

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 built 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?

user438383
  • 5,716
  • 8
  • 28
  • 43
user1631224
  • 409
  • 2
  • 6
  • 13
  • 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 Aug 28 '12 at 19:25
  • I'm not sure exactly how to do that?....Can you explain how? thanks – user1631224 Aug 28 '12 at 19:31
  • 1
    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 Aug 28 '12 at 19:33
  • After installing `g++` did you add it to Environment variables? – Srijan Aug 28 '12 at 19:42
  • 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 , it says "Unresolved inclusion: " – user1631224 Aug 28 '12 at 19:44
  • The binary is not found because there is no binary. The problem is on the side of creating the binary. – Marko Topolnik Aug 28 '12 at 19:45
  • @Jesse, hi, when I go to create a C++ project, I select Hello World C++ Project under the Executable folder, and on the right the only toolchain I see is MinGW GCC – user1631224 Aug 28 '12 at 20:03
  • @user1631224: Okay, I can only guess because I cannot see what you are exactly doing. Open up a command prompt and type `g++ --version`, what do you see? – Jesse Good Aug 28 '12 at 20:08
  • @Jesse, I get a "g++: fatal error: no input files compilation terminated" – user1631224 Aug 28 '12 at 20:23

4 Answers4

21

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)

Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
moskito-x
  • 11,832
  • 5
  • 47
  • 60
9

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
RS1980
  • 634
  • 8
  • 13
1

See here: http://www.youtube.com/watch?v=QhvXCg2CY4Q

dan
  • 13,132
  • 3
  • 38
  • 49
  • What do you mean by "tried"? There are the step by step instructions on how to install the plugin and create a functional c/c++ project in eclipse. – dan Aug 28 '12 at 19:33
  • Help -> Install New Software > type "http://download.eclipse.org/tools/cdt/releases/helios" -> Click Add -> Selected CDT Main Features and CDT Option Features even though the youtube video only had a few selected features because I wanted to see if it required any other dependencies, then downloaded and restart eclipse......nothing.......I "tried"...yes? – user1631224 Aug 28 '12 at 19:39
  • Your gcc is 4.6, can you try using gcc 4.0 that will compile using 32 bit, see: http://stackoverflow.com/questions/1668447/launch-failed-binary-not-found-snow-leopard-and-eclipse-c-c-ide-issue. – dan Aug 28 '12 at 19:47
  • OP is not using a Mac, but Windows. It is clear from the text of his question. – Marko Topolnik Aug 28 '12 at 19:52
  • @Marko I know that, but the issue is similar, and I suspect it's the same 64 vs 32 bit issue. – dan Aug 28 '12 at 19:55
  • But the error says that `g++` could not be found. I don't see this could be related. – Marko Topolnik Aug 28 '12 at 19:59
  • There are multiple errors, "Launch failed. Binary Not found" error." is the first one. – dan Aug 28 '12 at 20:01
  • I do have to mention that I dont see any binary file under my C++ project – user1631224 Aug 28 '12 at 20:08
  • dan, Binary Not found is an obvious consequence of *Cannot run program "g++": The system cannot find the file specified.* – Marko Topolnik Aug 28 '12 at 20:29
  • @marko, how would I be able to resolve this g++ issue, I tried typing g++ from a command line and it says "g++: fatal error: no input files compilation terminated" – user1631224 Aug 28 '12 at 20:36
  • @user1631224 That's a good sign, it means it is on the system PATH. The problem is, Eclipse doesn't see that path and fails to find your `g++` executable. I unfortunately don't know the details on how to configure Eclipse CDT. – Marko Topolnik Aug 28 '12 at 20:40
0

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.

oenpelli
  • 3,467
  • 2
  • 29
  • 20