简体   繁体   English

Eclipse - C ++ hello world项目的错误

[英]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 . 我使用的是64位Winodws 7.我已下载了CDT Eclipse并已下载MinGW After that, I created a c++ hello world project. 之后,我创建了一个c ++ hello world项目。 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 ." 但是当我想运行它时,会弹出这个错误:“启动失败。 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. 使用Eclipse for Java时,只需单击“运行”图标,然后Eclipse将自动编译您的程序,然后运行它。 With C++ however, this is for whatever reason not the case. 但是,使用C ++,无论出于何种原因,都是如此。 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. 这是Eclipse将创建makefile并编译程序的地方。 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? eclipse是否正确为您构建了EXE文件? Look for helloworld.exe or whatever, and try running it from a Windows Command prompt. 查找helloworld.exe或其他任何内容,并尝试从Windows命令提示符运行它。

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. 如果EXE文件存在,但无法在Eclipse中运行,请检查是否为项目启用了PE Windows二进制解析器

UPDATE : To fix "Unresolved Inclusion" errors, see here. 更新 :要修复“未解决的包含”错误, 请参阅此处。 In particular, try this: 特别是,试试这个:

  1. Right-click on the probject and select "Properties" 右键单击probject并选择“Properties”
  2. Go to "C/C++ General" -> "Paths and Symbols" and select "Includes" tab 转到“C / C ++ General” - >“路径和符号”,然后选择“包含”选项卡
  3. Select "GNU C++" 选择“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 查找文件夹“C:\\ dev \\ eclipse \\ mingw \\ lib \\ gcc \\ mingw32 \\ 4.4.1-dw2 \\ include \\ c ++”或类似文件夹

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 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. 问题是因为你的Windows是64位而Eclipse只是选择忽略这种格式的可执行文件而不报告任何错误。 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 右键单击项目 - >属性 - >在右侧窗格中展开“MinGW C ++ Liker”,然后选择“ 其他”选项

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. 重建您的应用程序,刷新,您应该看到包含可执行文件的Binaries文件夹。 You can run it by going to Run As -> Local C/C++ Application 您可以通过运行方式 - >本地C / C ++应用程序来运行它

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. 首先检查所选的工具链,同时创建新的c ++项目。它应该是你所说的MinGW,(希望你已经在环境变量中输入了)。编写代码.press ctrl + b来构建工作区。 Rt click the project and select clean project.press f5 to refresh.then ctrl+f11 to run your prg.Hope this helps.. Rt单击项目并选择清理project.press f5刷新。然后按ctrl + f11运行你的prg.Hope这有助于..

Make sure you select the correct Toolchain when you create the project. 确保在创建项目时选择正确的工具链。

在此输入图像描述

这是因为Windows执行权限(我假设您正在从外部驱动器或其他分区运行eclipse),如果您以管理员身份运行eclipse,您将能够毫无问题地调试应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM