OS X Eclipse C++启动失败 - 找不到二进制文件
我很困扰,因为这不应该让我这么头痛。我已经下载了适用于 MAC OS X 10.7.1 的最新 Eclipse Indigo 和所有 CDT C++ 插件/
安装上述 CDT 插件后重新启动后,我开发了一个简单的“hello world”C++ 应用程序并尝试运行该应用程序,“启动失败。找不到二进制文件。”错误信息。我已经阅读了多个修复程序,但没有一个起作用。我尝试将 -arch i386 标志添加到链接器和编译器命令中,但仍然没有成功。
有没有人成功让 Eclipse C++ 在 10.7.1 上运行??????这让我大吃一惊。我可以简单地在 VIM 中编写相同的程序,然后通过终端编译并执行。 ECLIPSE 不想一起玩。
我将深深感激任何可以提供帮助的人!!!!
编辑:编译器输出
**** 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 ****
I am quite troubled as this shouldn't be causing me such a headache. I've downloaded the most recent Eclipse Indigo and all CDT C++ plugins for MAC OS X 10.7.1/
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.
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.
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 ****
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(15)
我在运行 Snow Leopard 的 2007 Macbook 上使用带有 CDT 的 Eclipse Juno。我有两个症状:
我花了几个小时在谷歌上搜索答案,时间足够长,足以确定这两种症状表明了许多问题,这些问题在不到十年的时间里已经被报道过,但没有得到充分的解决。这就是一个问题,因为十年后应该有足够多的输入数据来提供一个故障排除程序,引导用户逐步消除所有可能的原因。
相反,几个小时以来,我读到了很多人的故事,其中许多人已经解决了他们的特定问题,但他们似乎都必须做一些稍微不同的事情才能到达那里。
这个问题应该不难解决。特别是在像我这样的情况下(但我不是唯一一个),当控制台视图显示没有错误的构建时,用户可以将二进制文件(Eclipse 奇怪地说它找不到)复制到桌面并运行它,而无需来自 Finder 或 bash 终端会话的任何问题。
所有这些似乎都相当强调Mach0 64 二进制解析器中缺乏足够的指示符,这些指示符应该被设计为准确地告诉我们它需要什么但它没有看到。
诚然,对于像我这样在 64 位 CPU 上运行 64 位操作系统 [Snow Leopard] 的 MacBook,这种情况会更加严重,不幸的是,制造商使用了 32 位启动内核。但是,请预先警告,我已经尝试过 -arch i386 g++ 开关,并将 g++ 重新链接到 g++-4.0,症状没有任何变化。
2012 年 7 月 10 日添加的附录:
我添加此清单是希望为未来几年无疑会提出这个问题的许多其他人澄清一种方法。这种方式反映了我发现在运行 Snow Leopard 的 Mac 上使用 Eclipse Juno 时的必要条件:
1) 转到 Preferences->C/C++->New CDT Project Wizard,并在 Preferred Toolchains 下,确保所有可执行项目类型设置为 MacOSX GCC。
2)这是一个大问题。我能够在项目资源管理器中获得一个 Binaries 文件夹,因此能够在构建项目后通过使用不包含点 ['.'] 的项目名称来运行该项目。这是我从这里的另一个答案中了解到的,该答案是在我上一条消息后几个小时编辑的。这一要求很容易被忽视,因此这是一个常见的要求,特别是如果您有 Eclipse 经验但仅限于其他语言,因为其他语言插件的教程 [例如 PyDev 或 Java] 经常要求您创建名称中带有点的项目。如果您在使用其他语言时养成了这种习惯,请在使用 CDT for C/C++ 时打破它。但请预先警告,这次仅右键单击并重命名现有项目名称(不使用点)是不够的。最简单的方法是删除旧项目并创建一个名称不带点的新项目。
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) 在项目属性中,而不是首选项中,转到 C/C++ Build->Settings,并在 Binary Parsers 下确保选中 Mach-O 64 Parser。确保选中此选项,而不是已弃用的 Mach-O 解析器。
5) 此时,构建项目后,项目资源管理器中应该会显示以下几项内容:
6) 现在项目文件夹下应该有一个 Binaries 文件夹。
7) 现在,该 Binaries 文件夹中应该是您的可执行文件。如果像我一样,您的 Mac 实际上是 32 位,那么它旁边应该有 [x86_64/le]。现在不是讨论您的 Mac 实际上是 32 位还是 64 位这一令人困惑的话题的最佳时机。如果你不知道,而且很多人不知道,因为苹果确实让人困惑,请查看这个小应用程序,可以从 http://www.ahatfullofsky.comuv.com/English/Programs/SMS/SMS.html 它会告诉你什么是真相。它是免费的,但“代价”是你必须滚动浏览页面顶部反映程序员政治倾向的广告。
I am using Eclipse Juno with CDT on a 2007 Macbook running Snow Leopard. I have the two symptoms:
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.
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 exactly what it needs which it is not seeing.
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.
ADDENDUM ADDED 10/07/2012:
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:
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.
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.
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 ...
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.
5) At this point, after you build your project, several things should be evident in the Project Explorer:
6) There should now be a Binaries folder under project's folder.
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.html which 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.
对于那些刚接触编程/Eclipse/IDE 并遇到相同错误但上述解决方案不起作用的人,我解决了“启动失败。找不到二进制文件”的问题。执行以下操作时出错:只需确保在尝试运行或调试之前构建项目(“项目”>“构建全部”)即可。我以为 IDE 会在我单击“调试”或“运行”时进行构建,但事实并非如此(显然,回想起来)。新手教训。构建后,您应该在项目的根目录下看到“Binaries”和“Debug”文件夹。
我使用的是 OS X 10.7.3,如果重要的话,尽管我认为我犯的错误是根本性的,任何 eclipse 发行版都会给出相同的错误。
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.
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.
在 Mac 上:
确保您已安装 xcode。通过编写“info g++”来测试它,您必须看到有关编译器的正确信息。
构建您的项目。
转到您的项目的文件夹。您应该在“调试”或“实现”文件夹中看到一个可执行文件,具体取决于您的构建配置。如果您按住 d 键单击可执行文件,您应该会在终端上看到结果。
返回 Ecliipse,从运行/运行配置...,然后浏览到包含可执行文件的文件夹(您已经找到了该文件夹),您还可以在该窗口中根据需要更改构建配置。并使每次运行自动构建。
再次运行应该可以了。
祝你好运 !
on mac:
Make sure you have xcode installed. Test it by writing "info g++" you must see proper information about the compiler.
Build your project.
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.
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.
Run again it should work.
Good luck !
我遇到了同样的问题,然后我在 this 上找到了解决方案网站。
让我简单解释一下;
I had the same problem, then I found a solution on this site.
Let me explain shortly;
您应该更改项目的设置以构建可执行文件而不是动态库:
调用:MacOS X C++ 链接器 g++ -arch i386 -dynamiclib -o "libHelloWorld" ./main.o`
转到项目属性 -> C/C++ 构建 ->设置->构建工件,然后在第一个下拉列表中选择可执行。
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`
Go to project properties -> C/C++ Build -> Settings -> Build artifact, and select Executable in the first drop down list.
我正在使用 Eclipse Oxygen,以下内容解决了我的问题:
右键单击您的项目并转到属性。导航至C/C++ 构建>工具链编辑器,然后在当前工具链中选择MacOSX GCC,然后应用并关闭。
使用CMD+B构建您的项目,然后运行它。
I am using Eclipse Oxygen and the following fixed my problem:
Right-click on your project and go to properties. Navigate to C/C++ Build > Tool Chain Editor and select MacOSX GCC in the Current toolchain, and Apply and Close.
Build your project with CMD+B and then run it.
我也遇到了同样的问题。答案可能很难找到,因为“找不到二进制文件”问题之前已经多次出现过,原因和解决方案各不相同(选择 64 位解析器等)。
事实证明,就我而言,解决方法很简单:您必须为您创建的每个新项目执行一次手动构建,只需一次。之后,一切如常。
详细信息:在 Mac OS 10.7.2 上使用全新安装的 Eclipse Indigo Service Release 1。
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.).
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.
如果您的项目名称包含“.” (点),构建项目时不会生成二进制文件。
从项目名称中删除所有“.”(点)并重建它或尝试创建一个新项目。
快乐编码!
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!
如果您可以成功构建,但尝试运行时出现错误:
可能的解决方案可能是添加带有二进制输出文件完整路径的新配置
(运行- >运行配置...->主->C++ 应用程序):
If you can successfully built but when try to run it getting error:
Possible solution could be adding new configuration with full path to your binary output file
(Run->Run Configuration...->Main->C++ Application):
我通过创建“启动配置”解决了 Eclipse 的类似问题。我正在 OSX Lion 上使用带有 CDT(C/C++ 开发环境)的 Indigo 版本的 Eclipse。我在“项目”->“属性”->“运行/调试设置”中找到了创建新启动配置的选项。
我在创建和构建空的“Hello World Ansi C Autotools 项目”后遇到了这个问题。构建过程创建了一个工作可执行文件 src/a.out。我可以从终端成功运行 a.out,但 Eclipse 并不知道这是我的项目的可执行文件,直到我创建了指向它的启动配置。一旦我这样做了,我就可以像往常一样使用绿色运行按钮运行 a.out 了。
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.
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.
即使我将工件设置为可执行文件,我也遇到了同样的问题。这是因为共享库设置被勾选,这会导致即使您指定了可执行文件也会生成 dylib。
I had the same problem, even when i had set the artifact to executable. It was because the shared lib setting was ticked and this causes a dylib to be made even though you have specified an executable.
我通过在项目属性对话框中的C/C++ Build 选项卡上将Builder Type 设置为Internal Builder 来运行它。
I go this to run by setting the Builder Type to Internal Builder on the C/C++ Build tab, in the project properties dialog.
无论在工作区中采取哪种方法来解决这个问题,这个问题似乎已经成为我创建的项目的固有问题。使用参数或确保链接的 gcc 版本都不起作用。我确实找到了一个直观的解决方案。这是:“...二进制不可用...”错误。
执行以下操作:(请记住,以下步骤是在您采取上述任一方法并且这些方法都没有解决问题之后进行的。1
.)删除所有内容 - 项目和文件。
2.) 创建新项目和源文件
No matter which approach to take to solve this issue on your workspace, this problem seemed to have become native to the project that I had created. Neither using the arguments or making sure the gcc version for linking did not work. I did find an intuitive solution. Here it is:to the "...binary not available..." error.
Do the following:(remember the following steps are after you have taken either of the above routes and none of those have solved the issue.
1.) delete everything - the project and the files.
2.) create new project and source files
我遇到了类似的问题,但代码不同。在 File.h 文件中,确保
上述语句显示析构函数已初始化 () 并用大括号 { } 定义。在我的代码中我忘记定义析构函数。
希望这有帮助
I had the similar issue but code was different. In File.h file make sure
Above statement shows destructor initialized () and defined with curly braces { } . In my code I forgot to define Destructor.
Hope this helps
我遇到了同样的问题,所以我稍微摆弄了一下,发现如果我单击“配置文件”按钮(绿色播放图标,下面有一个小时钟),在“运行”按钮的右侧,我的程序将在我下次单击“运行”按钮时运行。
我实际上不知道那是做什么的,但它允许我运行代码。
如果有人知道为什么这有帮助,以及它是否是一个实际的解决方案,请不要犹豫,relpy!
I was having the same problem, so I fiddled around a littpe bit and found out that if I clicked on the "profile" button (green play icon with a little clock under it), to the right of the "run" button, my program would Run the next time I clicked on the Run button.
I actually dont know what that did, but it allowed me to run the code.
if anybody knows why this helped, and whether it is an actual solution or not dont hesitate to relpy!