13

I am using a 64-bit Winodws 7. I've downloaded a CDT Eclipse and have downloaded MinGW. After that, I created a c++ hello world project. This is the code:

#include <iostream>
using namespace std;

int main() {
    cout << "!!!Hello World!!!" << endl; // This is supposed to print "Hello World!!!"
    return 0;
}

But when I want to run it, this error pops up: "Launch failed. Binary not found."

Any help would be highly welcomed.

Masoud
  • 1,354
  • 6
  • 18
  • 30
  • 1
    does your project compile? :) – ascanio May 16 '11 at 13:10
  • Seems similar to: http://stackoverflow.com/questions/4971926/launch-failed-binary-not-found-cdt-on-eclipse-helios – forsvarir May 16 '11 at 13:11
  • 1
    @forsvarir There is no answer there – Masoud May 16 '11 at 13:15
  • 1
    Rather long winded dicussion about setting up eclipse for windows can be found here (apparently it doesn't always recognise .EXE as executable or something): http://codingrecipes.com/eclipse-launch-failed-binary-not-found-and-netbeans – forsvarir May 16 '11 at 13:16
  • 2
    It is not helpful. I read it. – Masoud May 16 '11 at 13:21
  • 4
    That's quite the bold statement, "it is not helpful". Instead of shifting blame, perhaps try harder to understand. – Blindy May 16 '11 at 13:36
  • It takes more effort to get Eclipse C/C++ to work in Windows, than it does to manipulate strings in C, screw it. I'm using Dev-C++ from Bloodshed. I'll use Eclipse for Java. – Doug Molineux Aug 03 '12 at 21:28
  • @Pete Herbert Penito: I would recommend to use Visual C++ Express. It is ready just right away after being installed. – Maciek Talaska Sep 02 '12 at 08:19

6 Answers6

3

You have to "Build" your project before you can "Run" it. When using Eclipse for Java, you simply click the "Run" icon, then Eclipse will automaticly compile your program and then run it. With C++ however, this is for whatever reason not the case. Instead of just clicking the "Run" icon, you need to click the "Build" icon first. This is where Eclipse will create a makefile and compile your program. Then you can run it by clicking the "Run" icon.

I hope this solves your problem.

Teimpz
  • 945
  • 7
  • 8
2

Has eclipse built the EXE file correctly for you? Look for helloworld.exe or whatever, and try running it from a Windows Command prompt.

If not, then you've got a problem with your build. Build it again and check for errors.

If the EXE file is there, but cannot be run from within Eclipse then check that the PE Windows Binary Parser is enabled for your project.

UPDATE: To fix "Unresolved Inclusion" errors, see here. In particular, try this:

  1. Right-click on the probject and select "Properties"
  2. Go to "C/C++ General" -> "Paths and Symbols" and select "Includes" tab
  3. Select "GNU C++"
  4. Press on "Add..."
  5. Look for the folder "C:\dev\eclipse\mingw\lib\gcc\mingw32\4.4.1-dw2\include\c++" or similar

UPDATE See also this link:

http://wiki.eclipse.org/CDT/User/FAQ#I_am_using_a_non_gnu_compiler_and_I_get_the_following_messages:_.22Error_launching_external_scanner_info_generator_.28gcc_-E_-P_-v_-dD.22_and_.22File_not_indexed_because_it_was_not_built_.22._How_do_I_get_rid_of_them.3F

Roddy
  • 66,617
  • 42
  • 165
  • 277
  • @Roddy There is no exe file there. There is a error. Unresoleved inclussion. IOStream – Masoud May 16 '11 at 13:31
  • have you set up the paths to the include files? – ColWhi May 16 '11 at 13:39
  • I did that. That is solved. But there is another error. Description Resource Path Location Type Error launching external scanner info generator (gcc -E -P -v -dD C:/Users/Mahtab/workspace/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp) – Masoud May 16 '11 at 13:47
  • 1
    @Masoud. Google is *my* friend. Try and make it yours also! – Roddy May 16 '11 at 13:51
  • @Roddy: I used google. I tried lots of ways but nothing worked. – Masoud May 16 '11 at 13:58
  • 1
    @Masoud - please take the time to SAY IN YOUR QUESTION what you've tried, and what happened. We're not mind-readers, and the better your question, the more chance you'll have of getting useful answers. Also, "Nothing worked" isn't helpful. What error message are you getting now? – Roddy May 16 '11 at 14:07
2

The problem is because you Windows is 64 bit and Eclipse just sort of chooses to ignore executables in this format without reporting any error. Pretty convenient, huh? Try this to fix it:

Right-click your project -> Properties -> expand "MinGW C++ Liker" in the right side pane and select the Miscellaneous option

Under "Other options" you will add a new option:

-arch=i386

Rebuild your application, refresh, and you should see a Binaries folder that contains your executable. You can run it by going to Run As -> Local C/C++ Application

IcedDante
  • 6,145
  • 12
  • 57
  • 100
  • A bit late :), but I had to search to find the MinGW C++ LINKER location. For anyone else looking, the MinGW C++ Linker (not Liker) is in project > properties > C/C++ Build > Settings – user3771655 Jun 27 '15 at 01:23
0

First check the toolchain selected,while creating the new c++ project.It should be MinGW as you have stated,(hope you have made the entries in the environmental variables).Write the code .press ctrl+b to build the workspace. Rt click the project and select clean project.press f5 to refresh.then ctrl+f11 to run your prg.Hope this helps..

Omkar
  • 791
  • 1
  • 9
  • 26
0

Make sure you select the correct Toolchain when you create the project.

enter image description here

Rose Perrone
  • 61,572
  • 58
  • 208
  • 243
-1

This happens due to windows execution permission (I assume that you're running eclipse from an external drive or from another partition), if you run eclipse as an administrator you will be able to debug your application without problems..