2011-08-21 29 views
15

Tôi có hệ thống Lion (10.7.1) mà tôi đã cài đặt Xcode 4.2. Giả sử tôi có một chương trình C đơn giản helloWorld.c như sau:Làm cách nào để thêm hỗ trợ PPC/PPC64 vào Xcode 4.2 trong Lion?

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

Sử dụng thiết lập này, tôi muốn thử biên dịch helloWorld.c để sử dụng trên PPC và PPC64 kiến ​​trúc, ví dụ :

$ gcc -arch ppc helloWorld.c -o helloWorld 

này cung cấp cho các thông báo lỗi sau:

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 

Làm thế nào để khôi phục hỗ trợ cho PowerPC để cài đặt Xcode 4 của tôi?

Tôi đã thử các hướng dẫn được nêu trong this previous Stack Overflow post, nhưng các hướng dẫn này không hoạt động đối với cài đặt Lion của tôi.

Tôi đang sử dụng Xcode 3.2.6 installer located on Apple's dev site.

Từ các liên kết tượng trưng, ​​tôi nghi ngờ các hướng dẫn đó hoạt động đối với cài đặt 10.6, nhưng không phải 10.7.

Trong mọi trường hợp, một số tệp và thư mục nguồn từ cài đặt Xcode 3.2.6 không tồn tại để tạo liên kết tượng trưng, ​​hoặc được đặt ở nơi khác trong cài đặt Xcode 3. (Ví dụ: không có thư mục /Xcode3/usr/bin để từ đó liên kết mã nhị phân as.)

Có ai có may mắn khi biên soạn PPC và PPC64 nhị phân từ hệ thống Lion không?

Để được tặng thưởng, vui lòng viết câu trả lời chi tiết hợp lý. Đối với bản thân tôi, nhưng cũng cho hậu thế. :)

EDIT - 31 Aug 2011

Vì vậy, tôi đã cố gắng sửa đổi mà Laurent chỉ vào và có thêm cùng, nhưng điều này là không đủ để nhận được hỗ trợ PPC làm việc.

tôi đã thêm liên kết tượng trưng để cố gắng giúp gcc cùng trong việc tìm kiếm các nguồn lực cần thiết:

$ 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 

Khi tôi cố gắng biên dịch ứng dụng thử nghiệm của tôi, tôi nhận được rất nhiều lỗi:

$ 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 

Có lẽ có các tùy chọn biên dịch tôi nên thêm để trỏ đến các tiêu đề Xcode3, nhưng tôi đang tìm kiếm trong /Xcode3/usr/include và không thực sự có nhiều ở đó.

+0

Bạn có thể cố gắng chỉ định SDK cơ sở và/hoặc phiên bản GCC ("-sdk /Developer/SDKs/MacOSX10.5.sdk", "GCC_VERSION = 4.2") trên dòng lệnh không? Điều này sẽ buộc sử dụng GCC thay vì cầu LLVM/GCC. –

+0

Tôi đang sử dụng dòng lệnh. Chỉ định 'xuất GCC_VERSION = 4.2; gcc -arch ppc -sdk /Developer/SDKs/MacOSX10.5.sdk helloWorld.c -o helloWorld' có cùng lỗi. –

+0

Sai lầm của tôi, GCC_VERSION = 4.2 chỉ hoạt động khi sử dụng xcodebuild. Bạn có thể cố gắng chỉ định explictly trình biên dịch CC = gcc-4.2 hoặc CC =/usr/bin/gcc-4.2? –

Trả lời

9

Nếu bạn thực hiện cài đặt Xcode 3.2.6 cổ điển trên Lion, bộ công cụ Xcode bị tắt và chưa được cài đặt. Đó là lý do tại sao Xcode3/usr/bin không tồn tại.

Tôi khuyên bạn nên đọc các bài đăng sau (đọc cả hai bài viết trước khi tiếp tục). Chúng mô tả một mẹo để đánh lừa trình cài đặt để cài đặt mọi thứ.

Sau đó, bạn có thể áp dụng cho việc khôi phục the trick from the SO entry hỗ trợ UBND tỉnh trong Xcode.

Lưu ý: Tôi chưa thử nghiệm các bước trên, nhưng tôi rất sẵn lòng nghe phản hồi của bạn về điều đó. Hy vọng nó giúp.

Chỉnh sửa 04 tháng 9 năm 2011: Tôi đã quản lý để có được bàn tay của tôi trên một máy Lion để thực hiện một số thử nghiệm và có một số kết quả. Tôi đã thu thập chúng on my blog.

+0

Điều này có vẻ đầy hứa hẹn. Sẽ theo dõi nếu tôi tìm ra bất cứ điều gì. –

+1

Chỉ cần theo dõi, tôi đã đi xa hơn tôi đã làm trước đó, mặc dù nó không hoạt động. Cảm ơn, mặc dù! –

+0

Tôi đã thực hiện một số thử nghiệm và nhận được một số kết quả. Xem chỉnh sửa câu trả lời của tôi. –

Các vấn đề liên quan