簡體   English   中英

MacOSX上的g ++不能與-arch ppc64一起使用

[英]g++ on MacOSX doesn't work with -arch ppc64

我正在嘗試使用g ++在MacOSX上構建通用二進制文件。 但是,它並沒有真正起作用。 我試過這個簡單的虛擬代碼:

#include <iostream>
using namespace std;
int main() {
    cout << "Hello" << endl;
}

這很好用:

% g++ test.cpp -arch i386 -arch ppc -arch x86_64 -o test
% file test
test: Mach-O universal binary with 3 architectures
test (for architecture i386):   Mach-O executable i386
test (for architecture ppc7400):    Mach-O executable ppc
test (for architecture x86_64): Mach-O 64-bit executable x86_64

但是,這不是:

% g++ test.cpp -arch i386 -arch ppc -arch x86_64 -arch ppc64 -o test
In file included from test.cpp:1:
/usr/include/c++/4.2.1/iostream:44:28: error: bits/c++config.h: No such file or directory
In file included from /usr/include/c++/4.2.1/ios:43,
                 from /usr/include/c++/4.2.1/ostream:45,
                 from /usr/include/c++/4.2.1/iostream:45,
                 from test.cpp:1:
/usr/include/c++/4.2.1/iosfwd:45:29: error: bits/c++locale.h: No such file or directory
/usr/include/c++/4.2.1/iosfwd:46:25: error: bits/c++io.h: No such file or directory
In file included from /usr/include/c++/4.2.1/bits/ios_base.h:45,
                 from /usr/include/c++/4.2.1/ios:48,
                 from /usr/include/c++/4.2.1/ostream:45,
                 from /usr/include/c++/4.2.1/iostream:45,
                 from test.cpp:1:
/usr/include/c++/4.2.1/ext/atomicity.h:39:23: error: bits/gthr.h: No such file or directory
/usr/include/c++/4.2.1/ext/atomicity.h:40:30: error: bits/atomic_word.h: No such file or directory
...

知道為什么會這樣嗎?

我在MacOSX 10.6上。 我已經安裝了Xcode 3.2.2及其附帶的所有SDK。 GCC 4.2是默認值。 GCC 4.0會產生一些不同的錯誤,但表現相似。

Snow Leopard中刪除了ppc64支持。 如果您構建並鏈接到Mac OS X 10.5 SDK,您仍然可以使用ppc64。

在命令行中嘗試以下命令:

g++ test.cpp -arch i386 -arch ppc -arch x86_64 -arch ppc64 -mmacosx-version-min=10.5 -isysroot/Developer/SDKs/MacOSX10.5.sdk -DMACOSX_DEPLOYMENT_TARGET=10.5 -o test

或者對於10.4 SDK使用:

g++-4.0 test.cpp -arch i386 -arch ppc -arch x86_64 -arch ppc64 -mmacosx-version-min=10.4 -isysroot/Developer/SDKs/MacOSX10.4u.sdk -DMACOSX_DEPLOYMENT_TARGET=10.4 -o test

注意,如果要使用10.4 SDK,則必須使用gcc 4.0(或g ++ 4.0)。 Apple的GCC 4.2不支持10.4 SDK。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM