我有一个安装了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
,并没有那么多。
您可以尝试在命令行中指定基本SDK和/或GCC版本(“-sdk /Developer/SDKs/MacOSX10.5.sdk”,“GCC_VERSION = 4.2”)吗?这将强制使用GCC而不是LLVM/GCC桥接器。 –
我正在使用命令行。指定'export GCC_VERSION = 4.2; gcc -arch ppc -sdk /Developer/SDKs/MacOSX10.5.sdk helloWorld.c -o helloWorld'会产生相同的错误。 –
我的错误,GCC_VERSION = 4.2只适用于使用xcodebuild。你可以尝试指定编译器CC = gcc-4.2或CC =/usr/bin/gcc-4.2吗? –