I am trying to build a Universal binary on MacOSX with g++. However, it doesn't really work. I have tried with this simple dummy code:
#include <iostream>
using namespace std;
int main() {
cout << "Hello" << endl;
}
This works fine:
% 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
However, this does not:
% 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
...
Any idea why that is?
I am on MacOSX 10.6. I have installed Xcode 3.2.2 with all SDKs it comes with. GCC 4.2 is the default. GCC 4.0 produces some different errors, though behaves similar.
ppc64 support was dropped in Snow Leopard. You can still use ppc64 if you build and link against the Mac OS X 10.5 SDK.
Try the following command at the command line:
Or for the 10.4 SDK use:
Note, if you want to use the 10.4 SDK, you will have to use gcc 4.0 (or g++4.0 ). Apple's GCC 4.2 doesn't support the 10.4 SDK.