【问题标题】:How do I add PPC/PPC64 support back to Xcode 4.2 under Lion?如何在 Lion 下将 PPC/PPC64 支持添加回 Xcode 4.2?
【发布时间】:2011-10-31 12:52:36
【问题描述】:

我有一个安装了 Xcode 4.2 的 Lion (10.7.1) 系统。假设我有一个简单的C程序helloWorld.c如下:

#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

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

我已尝试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 年 8 月 31 日

所以我尝试了 Laurent 指出的修改并取得了进一步的进展,但这还不足以让 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 吗?
  • 谢谢,但这不起作用,也不能手动指定gcc-4.2 或指定/Xcode3/usr/bin/gcc-4.2

标签: xcode macos gcc osx-lion powerpc


【解决方案1】:

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

我建议您阅读以下帖子(在进一步阅读之前阅读它们)。他们描述了一个欺骗安装程序安装所有东西的技巧。

然后,您可以申请the trick from the SO entry 在 Xcode 中恢复 PPC 支持。

注意:我尚未测试上述步骤,但很高兴听到您对此的反馈。希望对您有所帮助。

2011 年 9 月 4 日编辑:我已经设法使用 Lion 机器进行一些实验并获得了一些结果。我已经收集了他们on my blog

【讨论】:

  • 这看起来很有希望。如果我发现任何事情会跟进。
  • 只是跟进,我比以前走得更远,尽管它最终没有奏效。不过谢谢!
  • 我做了一些实验,得到了一些结果。请参阅我的答案的编辑。
猜你喜欢
  • 1970-01-01
  • 2012-01-22
  • 1970-01-01
  • 2011-12-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-26
  • 1970-01-01
相关资源
最近更新 更多