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!!开发者_Python百科!" << 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.
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.
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:
- Right-click on the probject and select "Properties"
- Go to "C/C++ General" -> "Paths and Symbols" and select "Includes" tab
- Select "GNU C++"
- Press on "Add..."
- 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
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
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..
Make sure you select the correct Toolchain when you create the project.
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..
精彩评论