2011-08-21 57 views
15

我有一个安装了Xcode 4.2的Lion(10.7.1)系统。假设我有一个简单的C程序helloWorld.c如下:如何在Lion下将PPC/PPC64支持添加回Xcode 4.2?

#include <stdio.h> 
main() { 
    printf("hello, world\n"); 
} 

使用这个设置,我想尝试编译helloWorld.c对PPC和PPC64架构,例如使用

$ gcc -arch ppc helloWorld.c -o helloWorld 

这提供了以下错误信息:

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 

如何恢复对PowerPC的支持,我的Xcode 4的安装?

我尝试了this previous Stack Overflow post中列出的说明,但这些说明不适用于我的Lion安装。我正在使用Xcode 3.2.6 installer located on Apple's dev site

从符号链接,我怀疑这些说明适用于10.6安装,但不是10.7。

在任何情况下,Xcode 3.2.6安装中的一些源文件和目录不存在以用于从Xcode 3安装中创建符号链接或位于其他位置。 (例如,没有连接as二进制文件的/Xcode3/usr/bin目录。)

有没有人有过编译Lion系统的PPC和PPC64二进制文件?

要获得赏金,请写出合理详细的答案。为了我自己,也为了后世。 :)

编辑 - 2011

年08月31于是,我就洛朗指出,并得到了进一步沿着修改,但是这还不足以让PPC的支持工作。

我加了符号链接,试图帮助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 

当我试图编译我的测试应用程序,我得到了很多的错误:

$ 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 

也许有编译选项,我应该添加到指向Xcode3头,但我正在寻找/Xcode3/usr/include,并没有那么多。

+0

您可以尝试在命令行中指定基本SDK和/或GCC版本(“-sdk /Developer/SDKs/MacOSX10.5.sdk”,“GCC_VERSION = 4.2”)吗?这将强制使用GCC而不是LLVM/GCC桥接器。 –

+0

我正在使用命令行。指定'export GCC_VERSION = 4.2; gcc -arch ppc -sdk /Developer/SDKs/MacOSX10.5.sdk helloWorld.c -o helloWorld'会产生相同的错误。 –

+0

我的错误,GCC_VERSION = 4.2只适用于使用xcodebuild。你可以尝试指定编译器CC = gcc-4.2或CC =/usr/bin/gcc-4.2吗? –

回答

9

如果您在Lion上执行Xcode 3.2.6的经典安装,则Xcode工具集将被禁用并且未安装。这就是为什么Xcode3/usr/bin不存在。

我建议你阅读以下文章(在进一步阅读之前阅读他们两人)。他们描述了一个欺骗安装程序来安装一切的技巧。

然后,您可以在Xcode恢复PPC支持应用the trick from the SO entry

说明:我没有测试过上述步骤,但我很乐意听到您对此的反馈意见。希望能帮助到你。

编辑2011年09月04日:我已经设法让我的手在狮子机器上进行一些实验并得到了一些结果。我收集他们on my blog

+0

这看起来很有希望。如果我发现任何事情,我会跟进。 –

+1

为了跟进,我得到了比以前更进一步,尽管它最终没有奏效。不过谢谢! –

+0

我做了一些实验并得到了一些结果。查看我的答案的编辑。 –