“启动失败。找不到二进制文件。” Snow Leopard 和 Eclipse C/C++ IDE 问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1668447/
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
"Launch Failed. Binary Not Found." Snow Leopard and Eclipse C/C++ IDE issue
提问by Alex
Not a question, I've just scoured the internet in search of a solution for this problem and thought I'd share it with the good folks of SO. I'll put it in plain terms so that it's accessible to newbs. :) (Apologies if this is the wrong place -- just trying to be helpful.)
不是问题,我刚刚在互联网上搜索此问题的解决方案,并认为我会与 SO 的好人分享。我会说得通俗易懂,以便新手可以访问它。:)(抱歉,如果这是错误的地方 - 只是想提供帮助。)
This issue occurs with almost any user OS X Snow Leopard who tries to use the Eclipse C/C++ IDE, but is particularly annoying for the people (like me) who were using the Eclipse C/C++ IDE in Leopard, and were unable to work with Eclipse anymore when they upgraded. The issue occurs When users go to build/compile/link their software. They get the following error:
几乎所有尝试使用 Eclipse C/C++ IDE 的 OS X Snow Leopard 用户都会出现此问题,但对于在 Leopard 中使用 Eclipse C/C++ IDE 且无法工作的人(如我)来说尤其烦人升级后不再使用 Eclipse。当用户去构建/编译/链接他们的软件时会出现这个问题。他们收到以下错误:
Launch Failed. Binary Not Found.
启动失败。找不到二进制文件。
Further, the "binaries" branch in the project window on the left is simply nonexistent.
此外,左侧项目窗口中的“二进制文件”分支根本不存在。
THE PROBLEM: is that GCC 4.2 (the GNU Compiler Collection) that comes with Snow Leopard compiles binaries in 64-bit by default. Unfortunately, the linker that Eclipse uses does not understand 64-bit binaries; it reads 32-bit binaries. There may be other issues here, but in short, they culminate in no binary being generated, at least not one that Eclipse can read, which translates into Eclipse not finding the binaries. Hence the error.
问题:Snow Leopard 附带的 GCC 4.2(GNU 编译器集合)是否默认编译 64 位二进制文件。不幸的是,Eclipse 使用的链接器无法识别 64 位二进制文件;它读取 32 位二进制文件。这里可能还有其他问题,但简而言之,它们最终导致没有生成二进制文件,至少不是 Eclipse 可以读取的二进制文件,这意味着 Eclipse 找不到二进制文件。因此错误。
One solution is to add an -arch i686 flag when making the file, but manually making the file every time is annoying. Luckily for us, Snow Leopard also comes with GCC 4.0, which compiles in 32 bits by default. So one solution is merely to link this as the default compiler. This is the way I did it.
一种解决方案是在制作文件时添加 -arch i686 标志,但每次手动制作文件很烦人。对我们来说幸运的是,Snow Leopard 还带有 GCC 4.0,它默认编译为 32 位。因此,一种解决方案只是将其链接为默认编译器。我就是这样做的。
THE SOLUTION: The GCCs are in /usr/bin, which is normally a hidden folder, so you can't see it in the Finder unless you explicitly tell the system that you want to see hidden folders. Anyway, what you want to do is go to the /usr/bin folder and delete the path that links the GCC command with GCC 4.2 and add a path that links the GCC command with GCC 4.0. In other words, when you or Eclipse try to access GCC, we want the command to go to the compiler that builds in 32 bits by default, so that the linker can read the files; we do not want it to go to the compiler that compiles in 64 bits.
解决方案: GCC 位于 /usr/bin 中,它通常是一个隐藏文件夹,因此除非您明确告诉系统您想查看隐藏文件夹,否则您无法在 Finder 中看到它。无论如何,您要做的是转到/usr/bin文件夹并删除将GCC命令与GCC 4.2链接的路径,并添加将GCC命令与GCC 4.0链接的路径。换句话说,当你或者 Eclipse 尝试访问 GCC 时,我们希望命令转到默认构建为 32 位的编译器,以便链接器可以读取文件;我们不希望它进入以 64 位编译的编译器。
The best way to do this is to go to Applications/Utilities, and select the app called Terminal. A text prompt should come up. It should say something like "(Computer Name):~ (Username)$ " (with a space for you user input at the end). The way to accomplish the tasks above is to enter the following commands, entering each one in sequence VERBATIM, and pressing enter after each individual line.
执行此操作的最佳方法是转到“应用程序/实用程序”,然后选择名为“终端”的应用程序。应该出现文本提示。它应该说类似“(计算机名):~(用户名)$ ”(最后有一个空格供用户输入)。完成上述任务的方法是输入以下命令,逐字逐句输入,并在每行后按回车键。
cd /usr/bin
rm cc gcc c++ g++
ln -s gcc-4.0 cc
ln -s gcc-4.0 gcc
ln -s c++-4.0 c++
ln -s g++-4.0 g++
Like me, you will probably get an error that tells you you don't have permission to access these files. If so, try the following commands instead:
像我一样,您可能会收到一条错误消息,告诉您您无权访问这些文件。如果是这样,请尝试使用以下命令:
cd /usr/bin
sudo rm cc gcc c++ g++
sudo ln -s gcc-4.0 cc
sudo ln -s gcc-4.0 gcc
sudo ln -s c++-4.0 c++
sudo ln -s g++-4.0 g++
Sudo may prompt you for a password. If you've never used sudo before, try just pressing enter. If that doesn't work, try the password for your main admin account.
Sudo 可能会提示您输入密码。如果您以前从未使用过 sudo,请尝试按 Enter。如果这不起作用,请尝试使用您的主管理员帐户的密码。
OTHER POSSIBLE SOLUTIONS You may be able to enter build variables into Eclipse. I tried this, but I don't know enough about it. If you want to feel it out, the flag you will probably need is -arch i686. In earnest, GCC-4.0 worked for me all this time, and I don't see any reason to switch now. There may be a way to alter the default for the compiler itself, but once again, I don't know enough about it.
其他可能的解决方案 您可以将构建变量输入 Eclipse。我试过这个,但我对它的了解还不够。如果您想感受一下,您可能需要的标志是 -arch i686。说真的,GCC-4.0 一直在为我工作,我现在看不到任何切换的理由。可能有一种方法可以更改编译器本身的默认值,但我又一次对此知之甚少。
Hope this has been helpful and informative. Good coding!
希望这对您有所帮助和提供信息。好编码!
回答by Viren
just for records, after struggling for 30 minutes, i solved this problem on lion (mac 10.7) by selecting Mach-O 64 Parser and Elf Parser under : Project Menu -> Properties->C/c++ Build->Settings->Binary Parsers tab (first tab, or third tab on Eclipse Version: 3.7.2) [ while listening to sweet escape by gwen stefani lol ].
只是为了记录,在挣扎了 30 分钟后,我通过选择 Mach-O 64 Parser 和 Elf Parser 在 Lion (mac 10.7) 上解决了这个问题:项目菜单 -> 属性 -> C/c++ 构建 -> 设置 -> 二进制解析器选项卡(Eclipse 版本:3.7.2 上的第一个选项卡或第三个选项卡)[同时听 gwen stefani lol 的 Sweet escape ]。
回答by Charlie
I had been getting the same message of
我一直收到相同的消息
Launch Failed. Binary Not Found.
启动失败。找不到二进制文件。
because I had not realized I needed to ctrl-click on the project folder and select "Build Project." This does not have to be done in Java projects in Eclipse, so other beginners like myself might have the same problem.
因为我没有意识到我需要按住 ctrl 单击项目文件夹并选择“构建项目”。这在 Eclipse 中的 Java 项目中不一定要完成,因此其他像我这样的初学者可能会遇到同样的问题。
回答by none
as mentioned, this can be accomplished simply by adding the necessary flag in eclipse.
如前所述,这可以通过在 eclipse 中添加必要的标志来完成。
to do so open the properties window, then go to "c/c++ build" > "settings". In the tree view on the right go to "miscellaneous" of "MacOS X C Linker" and "GCC C compiler" and append in the textbox labelled ~"flags" : "-arch i686"
为此,请打开属性窗口,然后转到“c/c++ build”>“settings”。在右侧的树视图中,转到“MacOS XC 链接器”和“GCC C 编译器”的“杂项”并附加到标有 ~“flags” 的文本框中:“-arch i686”
回答by Evan McClure
I'm running Mac OSX 10.6.8, and my Eclipse had the Cross GCC toolchain installed. So, I did this:
我运行的是 Mac OSX 10.6.8,我的 Eclipse 安装了 Cross GCC 工具链。所以,我这样做了:
- Under the Properties for the project, select C/C++ Build -> Tool Chain editor.
- Change the Current toolchain from Cross GCC to MacOSX GCC.
- I also changed the Current builder to CDT Internal Builder. (I'm not sure if this mattered.)
- I left all the stuff under Settings alone.
- Rebuild. You should see a binary with the same name as your project in the Debug folder of your project.
- 在项目的 Properties 下,选择 C/C++ Build -> Tool Chain editor。
- 将当前工具链从 Cross GCC 更改为 MacOSX GCC。
- 我还将当前构建器更改为 CDT 内部构建器。(我不确定这是否重要。)
- 我把所有的东西都留在了设置下。
- 重建。您应该会在项目的 Debug 文件夹中看到与您的项目同名的二进制文件。
回答by Alex
Oh, one more thing Don't forget to make a record of your links before you change them! If you don't want to change the system wide settings, add a directory into PATH before /usr/bin (say, $HOME/bin), and make the symlinks there If you want to change back, here's the code I would use:
哦,还有一件事 不要忘记在更改链接之前记录它们!如果您不想更改系统范围的设置,请在 /usr/bin 之前的 PATH 中添加一个目录(例如 $HOME/bin),并在那里制作符号链接如果您想改回来,这是我将使用的代码:
cd /usr/bin
sudo rm cc gcc c++ g++
sudo ln -s gcc-4.2 cc
sudo ln -s gcc-4.2 gcc
sudo ln -s c++-4.2 c++
sudo ln -s g++-4.2 g++
You'll want to check your /usr/bin and look for a file that's like "gcc-4.x". If it isn't 4.0 or 4.2, substitute the version numbers above for the version number that you have.
您需要检查您的 /usr/bin 并查找类似于“gcc-4.x”的文件。如果它不是 4.0 或 4.2,请将上面的版本号替换为您拥有的版本号。
EDIT: Oh, I also have trouble running the 64-bit carbon Eclipse if I'm using GCC-4.0. However, the 32-bit Carbon works great.
编辑:哦,如果我使用 GCC-4.0,我也无法运行 64 位 carbon Eclipse。但是,32 位的 Carbon 效果很好。
回答by Brian Postow
I got a program called gcc_select that has a prefs file somewhere and will allow you swap back and forth between multiple versions of gcc...
我有一个名为 gcc_select 的程序,它在某处有一个 prefs 文件,可以让你在多个版本的 gcc 之间来回交换......
I think I got it from macports, but I'm not sure.
我想我是从 macports 得到的,但我不确定。
回答by Priestbait
"as mentioned, this can be accomplished simply by adding the necessary flag in eclipse.
“如上所述,这可以通过在 eclipse 中添加必要的标志来完成。
to do so open the properties window, then go to "c/c++ build" > "settings". In the tree view on the right go to "miscellaneous" of "MacOS X C Linker" and "GCC C compiler" and append in the textbox labelled ~"flags" : "-arch i686""
为此,请打开属性窗口,然后转到“c/c++ build”>“settings”。在右侧的树视图中,转到“MacOS XC 链接器”和“GCC C 编译器”的“杂项”并附加到标有 ~“flags” 的文本框:“-arch i686”
Note that, if you go this route, you can easily check your processor's architecture by invoking the command
请注意,如果您走这条路线,则可以通过调用命令轻松检查处理器的架构
uname -p
uname -p
in the Bash terminal (i.e. Terminal.app) and changing "-arch i686" to "-arch -i386".
在 Bash 终端(即 Terminal.app)中并将“-arch i686”更改为“-arch -i386”。
回答by user400418
Instead go to Project -> Properties; Select C/C++ Build -> Settings; Under Tool Settings change the C++ compiler and Linker commands from g++ to g++-4.0. If you are still getting any errors change the c compiler also to gcc-4.0. I changed the C compiler settings also to be on the safe side. Everything is working perfectly fine for me.
而是转到项目-> 属性;选择 C/C++ 构建 -> 设置;在工具设置下,将 C++ 编译器和链接器命令从 g++ 更改为 g++-4.0。如果您仍然遇到任何错误,请将 c 编译器也更改为 gcc-4.0。为了安全起见,我也更改了 C 编译器设置。一切对我来说都很好。
回答by uplearnedu.com
Hi I installed Eclipse 32 bit and works perfectly so far on mac Mountain lion. I was getting the Binary not found on compile but now with the 32 bit Eclipse no problem.
嗨,我安装了 Eclipse 32 位,目前在 mac Mountain lion 上运行良好。我在编译时找不到二进制文件,但现在使用 32 位 Eclipse 没问题。