Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse - C++ hello world project's error

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.

like image 956
Masoud Avatar asked May 16 '11 13:05

Masoud


2 Answers

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.

like image 116
Teimpz Avatar answered Sep 19 '22 11:09

Teimpz


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

like image 34
Roddy Avatar answered Sep 18 '22 11:09

Roddy