gpt4 book ai didi

macos - MacOSX 上的 g++ 不适用于 -arch ppc64

转载 作者:行者123 更新时间:2023-12-02 16:19:59 25 4
gpt4 key购买 nike

我正在尝试使用 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 产生一些不同的错误,但行为相似。

最佳答案

雪豹中删除了 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。

关于macos - MacOSX 上的 g++ 不适用于 -arch ppc64,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2830931/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com