如何在 Lion 下将 PPC/PPC64 支持添加回 Xcode 4.2?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7137480/
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
How do I add PPC/PPC64 support back to Xcode 4.2 under Lion?
提问by Alex Reynolds
I have a Lion (10.7.1) system on which I installed Xcode 4.2. Suppose I have a simple C program helloWorld.c
as follows:
我有一个安装了 Xcode 4.2 的 Lion (10.7.1) 系统。假设我有一个简单的 C 程序helloWorld.c
,如下所示:
#include <stdio.h>
main() {
printf("hello, world\n");
}
Using this setup, I would like to try to compile helloWorld.c
for use on PPC and PPC64 architectures, e.g.:
使用此设置,我想尝试编译helloWorld.c
以用于 PPC 和 PPC64 架构,例如:
$ gcc -arch ppc helloWorld.c -o helloWorld
This gives the following error message:
这给出了以下错误消息:
llvm-gcc-4.2: error trying to exec '/usr/bin/../llvm-gcc-4.2/bin/powerpc-apple-darwin11-llvm-gcc-4.2': execvp: No such file or directory
How do I restore support for PowerPC to my Xcode 4 installation?
如何在我的 Xcode 4 安装中恢复对 PowerPC 的支持?
I have tried the instructions outlined in this previous Stack Overflow post, but these instructions do not work for my Lion installation.
我已经尝试了之前 Stack Overflow 帖子中概述的说明,但这些说明不适用于我的 Lion 安装。
I am using the Xcode 3.2.6 installer located on Apple's dev site.
我正在使用Apple 开发站点上的Xcode 3.2.6 安装程序。
From the symbolic links, I suspect those instructions work for a 10.6 installation, but not 10.7.
从符号链接中,我怀疑这些说明适用于 10.6 安装,但不适用于 10.7。
In any case, some of the source files and directories from the Xcode 3.2.6 installation do not exist to make symbolic links from, or are located elsewhere in the Xcode 3 install. (For example, there is no /Xcode3/usr/bin
directory from which to link the as
binary.)
在任何情况下,Xcode 3.2.6 安装中的某些源文件和目录不存在以创建符号链接,或者位于 Xcode 3 安装中的其他位置。(例如,没有/Xcode3/usr/bin
链接as
二进制文件的目录。)
Has anyone had luck with compiling PPC and PPC64 binaries from a Lion system?
有没有人有幸从 Lion 系统编译 PPC 和 PPC64 二进制文件?
To be awarded the bounty, please write a reasonably detailed answer. For myself, but also for posterity. :)
要获得赏金,请写出合理详细的答案。为自己,也为子孙后代。:)
EDIT - 31 Aug 2011
编辑 - 2011 年 8 月 31 日
So I tried the modifications that Laurent pointed to and got further along, but this was not enough to get PPC support working.
所以我尝试了 Laurent 指出的修改并进一步推进,但这还不足以让 PPC 支持工作。
I added symbolic links to try to help gcc
along in finding the resources it needs:
我添加了符号链接以尝试帮助gcc
查找所需的资源:
$ sudo ln -s /Xcode3/usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-gcc-4.2 /usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-gcc-4.2
$ sudo ln -s /Xcode3/usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-g++-4.2 /usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-g++-4.2
$ sudo ln -s /Xcode3/usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-gcc-4.2 /usr/llvm-gcc-4.2/bin/powerpc-apple-darwin11-llvm-gcc-4.2
$ sudo ln -s /Xcode3/usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-g++-4.2 /usr/llvm-gcc-4.2/bin/powerpc-apple-darwin11-llvm-g++-4.2
When I tried to compile my test app, I get a lot of errors:
当我尝试编译我的测试应用程序时,我收到了很多错误:
$ gcc -arch ppc helloWorld.c -o helloWorld
powerpc-apple-darwin11-llvm-gcc-4.2: 2: No such file or directory
In file included from /usr/include/stdio.h:64,
from helloWorld.c:1:
/usr/include/sys/cdefs.h:540:4: error: #error Unknown architecture
In file included from /usr/include/sys/_types.h:33,
from /usr/include/_types.h:27,
from /usr/include/stdio.h:67,
from helloWorld.c:1:
/usr/include/machine/_types.h:36:2: error: #error architecture not supported
In file included from /usr/include/_types.h:27,
from /usr/include/stdio.h:67,
from helloWorld.c:1:
/usr/include/sys/_types.h:94: error: expected ‘=', ‘,', ‘;', ‘asm' or ‘__attribute__' before ‘__darwin_blkcnt_t'
/usr/include/sys/_types.h:95: error: expected ‘=', ‘,', ‘;', ‘asm' or ‘__attribute__' before ‘__darwin_blksize_t'
/usr/include/sys/_types.h:96: error: expected ‘=', ‘,', ‘;', ‘asm' or ‘__attribute__' before ‘__darwin_dev_t'
/usr/include/sys/_types.h:99: error: expected ‘=', ‘,', ‘;', ‘asm' or ‘__attribute__' before ‘__darwin_gid_t'
/usr/include/sys/_types.h:100: error: expected ‘=', ‘,', ‘;', ‘asm' or ‘__attribute__' before ‘__darwin_id_t'
/usr/include/sys/_types.h:101: error: expected ‘=', ‘,', ‘;', ‘asm' or ‘__attribute__' before ‘__darwin_ino64_t'
/usr/include/sys/_types.h:103: error: expected ‘=', ‘,', ‘;', ‘asm' or ‘__attribute__' before ‘__darwin_ino_t'
/usr/include/sys/_types.h:107: error: expected ‘=', ‘,', ‘;', ‘asm' or ‘__attribute__' before ‘__darwin_mach_port_name_t'
/usr/include/sys/_types.h:108: error: expected ‘=', ‘,', ‘;', ‘asm' or ‘__attribute__' before ‘__darwin_mach_port_t'
/usr/include/sys/_types.h:109: error: expected ‘=', ‘,', ‘;', ‘asm' or ‘__attribute__' before ‘__darwin_mode_t'
/usr/include/sys/_types.h:110: error: expected ‘=', ‘,', ‘;', ‘asm' or ‘__attribute__' before ‘__darwin_off_t'
/usr/include/sys/_types.h:111: error: expected ‘=', ‘,', ‘;', ‘asm' or ‘__attribute__' before ‘__darwin_pid_t'
/usr/include/sys/_types.h:131: error: expected ‘=', ‘,', ‘;', ‘asm' or ‘__attribute__' before ‘__darwin_sigset_t'
/usr/include/sys/_types.h:132: error: expected ‘=', ‘,', ‘;', ‘asm' or ‘__attribute__' before ‘__darwin_suseconds_t'
/usr/include/sys/_types.h:133: error: expected ‘=', ‘,', ‘;', ‘asm' or ‘__attribute__' before ‘__darwin_uid_t'
/usr/include/sys/_types.h:134: error: expected ‘=', ‘,', ‘;', ‘asm' or ‘__attribute__' before ‘__darwin_useconds_t'
...
/usr/include/secure/_stdio.h:62: error: expected ‘=', ‘,', ‘;', ‘asm' or ‘__attribute__' before ‘__DARWIN_LDBL_COMPAT'
/usr/include/secure/_stdio.h:67: error: expected declaration specifiers or ‘...' before ‘size_t'
/usr/include/secure/_stdio.h:67: error: expected declaration specifiers or ‘...' before ‘size_t'
/usr/include/secure/_stdio.h:68: error: expected declaration specifiers or ‘...' before ‘va_list'
/usr/include/secure/_stdio.h:69: error: expected ‘=', ‘,', ‘;', ‘asm' or ‘__attribute__' before ‘__DARWIN_LDBL_COMPAT'
helloWorld.c:3: error: expected declaration specifiers before ‘main'
helloWorld.c:5: error: old-style parameter declarations in prototyped function definition
/usr/include/stdio.h:252: error: parameter name omitted
/usr/include/stdio.h:252: error: parameter name omitted
helloWorld.c:5: error: expected ‘{' at end of input
Perhaps there compilation options I should add to point to Xcode3 headers, but I'm looking in /Xcode3/usr/include
and there's not really much there.
也许我应该添加一些编译选项来指向 Xcode3 头文件,但我正在查看/Xcode3/usr/include
并且那里并没有太多。
回答by Laurent Etiemble
If you perform a classical install of Xcode 3.2.6 on Lion, the Xcode toolset is disabled and is not installed. That's why the Xcode3/usr/bin
does not exists.
如果您在 Lion 上执行 Xcode 3.2.6 的经典安装,则 Xcode 工具集将被禁用且未安装。这就是为什么Xcode3/usr/bin
不存在的原因。
I suggest you to read the following posts (read both of them before going further). They describe a trick to fool the installer into installing everything.
我建议您阅读以下帖子(在进一步阅读之前阅读这两篇文章)。他们描述了一种欺骗安装人员安装所有内容的技巧。
Then, you can apply the trick from the SO entryfor restoring PPC support in Xcode.
然后,您可以应用SO 条目中的技巧来恢复 Xcode 中的 PPC 支持。
Note:I have not tested the steps above, but I will be glad to hear your feedback on it. Hope it helps.
注意:我尚未测试上述步骤,但我很高兴听到您的反馈。希望能帮助到你。
Edit 04 Sep. 2011: I have managed to get my hands on a Lion machine to make some experiments and got some results. I have gathered them on my blog.
2011 年 9 月 4 日编辑:我已经设法在 Lion 机器上进行了一些实验并得到了一些结果。我在我的博客上收集了它们。