OS X Eclipse C++ 启动失败 - 找不到二进制文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7473259/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 17:00:43  来源:igfitidea点击:

OS X Eclipse C++ Launch Failed - Binary Not Found

c++eclipsemacoseclipse-cdtosx-lion

提问by 5k1zk17

I am quite troubled as this shouldn't be causing me such a headache. I've downloaded the most recent Eclipse Indigo and allCDT C++ plugins for MAC OS X 10.7.1/

我很烦恼,因为这不应该让我如此头疼。我已经为 MAC OS X 10.7.1/下载了最新的 Eclipse Indigo 和所有CDT C++ 插件

Upon restarting after installing the above CDT plugins, I've developed a simple 'hello world' c++ application and have tried running the application, "Launch failed. Binary not found." error message. I've read multiple fixes but none have worked. I tried adding the -arch i386 flag to the linker and compiler commands, still no luck.

安装上述 CDT 插件后重新启动后,我开发了一个简单的“hello world”c++ 应用程序并尝试运行该应用程序,“启动失败。找不到二进制文件。” 错误信息。我已经阅读了多个修复程序,但没有一个奏效。我尝试将 -arch i386 标志添加到链接器和编译器命令中,但仍然没有运气。

Has anyone successfully gotten Eclipse C++ running on 10.7.1?????? This blows my mind. I can simply write the same program in VIM and compile it just fine via the terminal and execute just fine. ECLIPSE DOESN'T WANT TO PLAY ALONG.

有没有人成功地让 Eclipse C++ 在 10.7.1 上运行??????这让我大吃一惊。我可以简单地在 VIM 中编写相同的程序,然后通过终端编译它并执行得很好。ECLIPSE 不想一起玩。

I will be deeply indebted to anyone who can help!!!!!

我将深深地感谢任何可以提供帮助的人!!!!!

EDIT:compiler output

编辑:编译器输出

**** Build of configuration Debug for project HelloWorld ****
make all Building file: ../main.cpp
Invoking: GCC C++ Compiler g++ -I/Developer/SDKs/MacOSX10.6.sdk/usr/include -O0 -g3 -Wall -c -fmessage-length=0 -arch i386 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp"
Finished building: ../main.cpp
Building target: libHelloWorld
Invoking: MacOS X C++ Linker g++ -arch i386 -dynamiclib -o "libHelloWorld" ./main.o
Finished building target: libHelloWorld
**** Build Finished ****

回答by istlota

I am using Eclipse Juno with CDT on a 2007 Macbook running Snow Leopard. I have the two symptoms:

我在运行 Snow Leopard 的 2007 Macbook 上使用带有 CDT 的 Eclipse Juno。我有两个症状:

  1. No Binaries folder in Project Explorer, and
  2. The 'Launch failed. Binary not found' error.
  1. 项目资源管理器中没有 Binaries 文件夹,以及
  2. '发射失败。找不到二进制文件'错误。

I have spent hours searching on Google for an answer, long enough to ascertain that these two symptoms are indicative of any number of problems which have been reported for not quite a decade without adequate resolution. That is a problem right there because after a decade there should have been more than enough input data to provide one troubleshooting procedure somewhere which walks the user step by step through the elimination of all possible causes.

我花了几个小时在谷歌上搜索答案,时间长到足以确定这两个症状表明存在任何数量的问题,这些问题已经报告了不到十年的时间,但没有得到足够的解决。这是一个问题,因为十年后应该有足够多的输入数据来提供一个故障排除程序,引导用户逐步消除所有可能的原因。

Instead, for hours I have read about a multitude of people, many of whom have resolved their particular problem but all of them seeming to have had to do something slightly different to get there.

取而代之的是,几个小时以来,我已经阅读了许多人的信息,其中许多人已经解决了他们的特定问题,但他们似乎都必须做一些稍微不同的事情才能到达那里。

This should not be that difficult to resolve. Particularly in cases such as mine [but I am not the only one] when the Console view displays a Build with no errors yet the user can copy the binary file [which Eclipse bizarrely says it can not find] to the Desktop and run it without any problems from either Finder or a bash terminal session.

这应该不难解决。特别是在像我这样的情况下 [但我不是唯一的] 当控制台视图显示一个没有错误的构建但用户可以将二进制文件 [Eclipse 奇怪地说它找不到] 复制到桌面并在没有错误的情况下运行它Finder 或 bash 终端会话中的任何问题。

All of this seems to be pointing rather emphatically toward the lack of adequate indicators in the Mach0 64 binary parser which should be designed to tell us exactlywhat it needs which it is not seeing.

所有这一切似乎都在着重指出Mach0 64 二进制解析器中缺乏足够的指标,该指标应该被设计为准确地告诉我们它没有看到它需要什么

Admittedly, this is exacerbated in the case of MacBooks like mine which are running a 64bit OS [Snow Leopard] on a 64bit CPU which the manufacturer, unfortunately, hamstrung with a 32-bit bootup kernel. But, be forewarned, I have already tried the -arch i386 g++ switch, and the relinking of g++ to g++-4.0 without any change in the symptoms.

诚然,对于像我这样在 64 位 CPU 上运行 64 位操作系统 [Snow Leopard] 的 MacBook,这种情况更加严重,不幸的是,制造商在 32 位启动内核上受阻。但是,预先警告,我已经尝试过 -arch i386 g++ 开关,以及将 g++ 重新链接到 g++-4.0 而症状没有任何变化。

ADDENDUM ADDED 10/07/2012:

2012 年 7 月 10 日添加的附录:

I am adding this checklist in the hope of clarifying a Way for the undoubtedly many others who will ask this question in the years to come. This Way reflects what I found to be necessary when using Eclipse Juno with a Mac running Snow Leopard:

我添加这个清单是希望为未来几年将提出这个问题的许多其他人澄清一条道路。这种方式反映了我在运行 Snow Leopard 的 Mac 上使用 Eclipse Juno 时发现的必要条件:

1) Go to Preferences->C/C++->New CDT Project Wizard, and under Preferred Toolchains, make sure all the Executable project types are set to MacOSX GCC.

1) 转到 Preferences->C/C++->New CDT Project Wizard,在 Preferred Toolchains 下,确保所有 Executable 项目类型都设置为 MacOSX GCC。

2) This is a biggie. I was able to get a Binaries folder in Project Explorer, and hence be able to run the project after building it, by using a Project name which does not contain dots ['.']. This I learned from another answer here, edited a few hours after my previous message. This requirement is easy to miss, hence a common one particularly if you are Eclipse experienced but only with other languages, because tutorials for other language plugins [such as with PyDev or for Java] frequently have you create Projects with dots in the name. If you have developed that habit with other languages, break it when using CDT for C/C++. Be forewarned, however, that it is not enough to just do a Right-Click and Rename an existing project name this time not using dots. The simplest Way is to delete your old project and create a new one with a name without dots.

2)这是一个大问题。通过使用不包含点 ['.'] 的项目名称,我能够在项目资源管理器中获得一个 Binaries 文件夹,因此能够在构建项目后运行该项目。这是我从这里的另一个答案中学到的,在我上一条消息后几个小时进行了编辑。这个要求很容易被忽略,因此很常见,特别是如果您有 Eclipse 经验但只使用其他语言,因为其他语言插件的教程 [例如 PyDev 或 Java] 经常让您创建名称中带有点的项目。如果您已经在其他语言中养成了这种习惯,那么在将 CDT 用于 C/C++ 时打破它。但是,请预先警告,这次不使用点仅执行右键单击并重命名现有项目名称是不够的。

3) There are many websites cautioning you to make sure you either use the -arch i386 compiler switch or change the links for /usr/bin/gcc and /usr/bin/g++ to point to gcc-4.0 and g++-4.0 instead of gcc-4.2 and g++-4.2. I created a bash script to ease switching back and forth and investigated if this was necessary. It was not, at least not with my Macbook. Based on what I read at one site from a Mach-O developer, I suspect that the current version of Mach-0 64 goes both ways. Which is a good segue to ...

3) 有许多网站提醒您确保使用 -arch i386 编译器开关或将 /usr/bin/gcc 和 /usr/bin/g++ 的链接更改为指向 gcc-4.0 和 g++-4.0 而不是gcc-4.2 和 g++-4.2。我创建了一个 bash 脚本来简化来回切换并调查是否有必要。不是,至少不是我的 Macbook。根据我在一个站点上从 Mach-O 开发人员那里读到的信息,我怀疑当前版本的 Mach-0 64 是双向的。这是一个很好的继续......

4) In the Project Properties, not Preferences, go to C/C++ Build->Settings and under Binary Parsers make sure Mach-O 64 Parser is checked. Make sure this, and not the deprecated Mach-O parser, is checked.

4) 在项目属性而不是首选项中,转到 C/C++ Build->Settings 并在 Binary Parsers 下确保选中 Mach-O 64 Parser。确保选中此项,而不是已弃用的 Mach-O 解析器。

5) At this point, after you build your project, several things should be evident in the Project Explorer:

5) 此时,在您构建您的项目之后,Project Explorer 中应该有几件事情是显而易见的:

6) There should now be a Binaries folder under project's folder.

6) 现在项目文件夹下应该有一个 Binaries 文件夹。

7) Within that Binaries folder should now be your executable file. It should have [x86_64/le] next to it if, like me, your Mac is effectively 32bit. Now is not the best time to get into the confusing topic of whether your Mac is effectively 32bit or 64bit. If you do not know, and a lot folks don't because Apple does make it confusing, check out the little app which can be downloaded from http://www.ahatfullofsky.comuv.com/English/Programs/SMS/SMS.htmlwhich will tell you What Is Truth. It is free, but the 'price' is that you have to scroll pass the ads at the top of the page reflecting the programmer's political disposition.

7) 在那个 Binaries 文件夹中现在应该是你的可执行文件。如果像我一样,您的 Mac 实际上是 32 位,那么它旁边应该有 [x86_64/le]。现在不是讨论 Mac 是有效的 32 位还是 64 位这一令人困惑的话题的最佳时机。如果您不知道,而且很多人不知道,因为 Apple 确实让人感到困惑,请查看可以从http://www.ahatfullofsky.comuv.com/English/Programs/SMS/SMS下载的小应用程序。 html,它会告诉你什么是真相。它是免费的,但“代价”是你必须滚动页面顶部的反映程序员倾向的广告。

回答by Nate

For those of you that are new to programming/eclipse/IDEs and get the same error but the solutions above don't work, I solved my "Launch Failed. Binary Not Found." error by doing the following: Simply be sure to build your project ("Project" > "Build All") before attempting to run or debug. I was thinking that the IDE would do the building when I clicked debug or run, but that is not the case (obviously, in retrospect). Newbie lesson learned. Once you build you should see a "Binaries" and "Debug" folder under the root directory of the project.

对于那些不熟悉编程/eclipse/IDE 并遇到相同错误但上述解决方案不起作用的人,我解决了我的“启动失败。找不到二进制文件”。执行以下操作会出错:只需确保在尝试运行或调试之前构建您的项目(“项目”>“全部构建”)。我想当我单击调试或运行时 IDE 会进行构建,但事实并非如此(显然,回想起来)。新手学习了。构建后,您应该会在项目的根目录下看到“二进制文件”和“调试”文件夹。

I was using OS X 10.7.3, if it matters, though I assume the mistake I made is fundamental and any eclipse distro would give the same error.

如果重要的话,我使用的是 OS X 10.7.3,但我认为我犯的错误是根本性的,任何 eclipse 发行版都会给出相同的错误。

回答by telcom_un

on mac:

在 Mac 上:

  1. Make sure you have xcode installed. Test it by writing "info g++" you must see proper information about the compiler.

  2. Build your project.

  3. Go to the folder of your project. You should see an executable file in Debug or realise folder, depending to your building configurations. If you d-click on the executable file you should see the result on the terminal.

  4. Back to Ecliipse, from Run/Run Configurations... and then browse to the folder that you have the executable file - one you already found - you can also change build configurations as you wish in that window. And make build automatic for each run.

  5. Run again it should work.

  1. 确保你已经安装了 xcode。通过编写“info g++”来测试它,您必须看到有关编译器的正确信息。

  2. 构建您的项目。

  3. 转到项目的文件夹。根据您的构建配置,您应该会在 Debug 或实现文件夹中看到一个可执行文件。如果您单击可执行文件,您应该会在终端上看到结果。

  4. 回到 Ecliipse,从 Run/Run Configurations... 然后浏览到您拥有可执行文件的文件夹 - 您已经找到了 - 您还可以根据需要在该窗口中更改构建配置。并为每次运行自动构建。

  5. 再次运行它应该可以工作。

Good luck !

祝你好运 !

回答by Fraukn

I had the same problem, then I found a solution on this site. Let me explain shortly;

我遇到了同样的问题,然后我在此站点上找到了解决方案。让我简短地解释一下;

  1. Create your c++ project,
  2. Have a look at project properties(?I),
  3. Select Mach-O parser under binary properties,
  4. Write your codes down,
  5. Do not forget building your project (?B) before run.
  1. 创建你的 C++ 项目,
  2. 看看项目属性(?I),
  3. 在二进制属性下选择 Mach-O 解析器,
  4. 写下你的代码,
  5. 不要忘记在运行之前构建您的项目 (?B)。

回答by Antonio Pérez

You should change the settings for your project to build an executable instead of a dynamic library:

您应该更改项目的设置以构建可执行文件而不是动态库:

Invoking: MacOS X C++ Linker g++ -arch i386 -dynamiclib -o "libHelloWorld"./main.o`

Invoking: MacOS X C++ Linker g++ -arch i386 -dynamiclib -o "libHelloWorld"./main.o`

Go to project properties -> C/C++ Build -> Settings -> Build artifact, and select Executablein the first drop down list.

转到项目属性 -> C/C++ Build -> Settings -> Build artifact,然后在第一个下拉列表中选择Executable

回答by Maihan Nijat

I am using Eclipse Oxygen and the following fixed my problem:

我正在使用 Eclipse Oxygen,以下解决了我的问题:

Eclipse Oxygen

日蚀氧气

Right-click on your project and go to properties. Navigate to C/C++ Build > Tool Chain Editorand select MacOSX GCCin the Current toolchain, and Apply and Close.

右键单击您的项目并转到properties。导航到C / C ++编译>工具链编辑器,然后选择MacOSX的GCC当前工具链,以及应用和关闭

Build your project with CMD+Band then run it.

使用CMD+B构建您的项目,然后运行它。

回答by 0x8BADF00D

If you can successfully builtbut when try to run it getting error:

如果您可以成功构建但尝试运行它时出现错误:

enter image description here

在此处输入图片说明

Possible solution could be adding new configuration with full path to your binary output file

可能的解决方案可能是添加带有二进制输出文件完整路径的新配置

(Run->Run Configuration...->Main->C++ Application):

运行->运行配置...->Main->C++ 应用程序):

enter image description here

在此处输入图片说明

回答by Harrison Brace

I was having the same problem. The answer can be hard to find as the "binary not found" issue has cropped up several times before, with different causes and solutions (selecting the 64-bit parser, etc.).

我遇到了同样的问题。答案可能很难找到,因为“找不到二进制文件”问题之前曾多次出现,原因和解决方案各不相同(选择 64 位解析器等)。

It turns out that, in my case, the fix was simple: you have to do a manual build, just once, for every new project you create. After that, works as usual.

事实证明,就我而言,修复方法很简单:您必须为您创建的每个新项目手动构建一次,只需一次。之后,照常工作。

Details: using a fresh fresh install of Eclipse Indigo Service Release 1 on Mac OS 10.7.2.

详细信息:在 Mac OS 10.7.2 上使用全新安装的 Eclipse Indigo Service Release 1。

回答by Sushant Kr

If your project name contains a "." (dot), the binary file will not be generated on building project. Remove all the "."(dots) from the project name and rebuilt it or try creating a new project.

如果您的项目名称包含“.” (点),在构建项目时不会生成二进制文件。从项目名称中删除所有“.”(点)并重建它或尝试创建一个新项目。

Happy coding!

快乐编码!

回答by Kevin Olree

I solved a similar problem with Eclipse by creating a "Launch Configuration". I am using the Indigo release of Eclipse on OSX Lion with CDT (C/C++ dev environment). I found the option to create a new launch configuration in Project->Properties->Run/Debug Settings.

我通过创建“启动配置”解决了 Eclipse 的类似问题。我在带有 CDT(C/C++ 开发环境)的 OSX Lion 上使用 Eclipse 的 Indigo 版本。我在项目-> 属性-> 运行/调试设置中找到了创建新启动配置的选项。

I encountered this problem after creating and building an empty "Hello World Ansi C Autotools Project". The build process created a working executable as src/a.out. I could run a.out successfully from the terminal but Eclipse did not understand that this was an executable for my project until I created a launch configuration pointing to it. Once I did that I was able to run a.out as usual using the green run button.

我在创建和构建一个空的“Hello World Ansi C Autotools 项目”后遇到了这个问题。构建过程创建了一个可用的可执行文件作为 src/a.out。我可以从终端成功运行 a.out 但 Eclipse 不知道这是我项目的可执行文件,直到我创建了指向它的启动配置。一旦我这样做了,我就可以像往常一样使用绿色运行按钮运行 a.out。