-->

How do I build Universal binaries (ppc/i386) using

2019-05-09 19:07发布

问题:

I am trying to build a universal binary for a project at work, but I can't seem to get Xcode set up properly to do so.

I am familiar with the Apple Documentation regarding this, but apparently I am not reading it correctly.

The Xcode build options in question seem to be:

  • Architectures
  • Base SDK
  • C/C++ Compiler Version
  • Mac OS X Deployment Target

In my settings I have the following Valid Architectures: i386 ppc ppc64 ppc7400 ppc970 x86_64.

If I use the following options, I get a binary with i386 and ppc970:

  • Architectures: i386 ppc
  • Base SDK: Mac OS X 10.5
  • C/C++ Compiler Version: GCC 4.0
  • Mac OS X Deployment Target: Mac OS X 10.5

I have several questions about this:

  1. Why ppc970 and not ppc7400 (or simply ppc)?
  2. What is the difference between the ppcs (ppc, ppc64, ppc7400, ppc970)?
  3. How do I get a binary for any ppc?

Apparently, I need a binary with ppc7400 to work on the Mac Mini we have for testing. The Mini has a G4 and is running OSX 10.5.8. From what I can tell, a binary with ppc7400 works but not one with only ppc970.

I have tried several combinations of the above build options, including changing my Base SDK to 10.4u. The above configuration is the only one that even builds. Other builds fail, often because of not recognizing header files or clearly available #defines. For example, if I change my compiler to gcc 4.2, I get errors searching for stdarg.h because of the #include_next directive and no clear path to correct headers. If I drop my Base SDK to 4.0, #define FSIZE long long is no longer recognized despite not changing any includes.

I'd really appreciate any insight you can give me on this.


EDIT UPDATE

Thanks for the info. I understand the flags now. But I get a strange result.

These are my build flags now:

GCC_VERSION = 4.0 MACOSX_DEPLOYMENT_TARGET = 10.4 SDKROOT = macosx10.5 GCC_MODEL_TUNING = G3

This produces object file (.o) that have arch 'ppc' as shown by lipo. All the included libs and frameworks are either 'ppc' or 'ppc7400' (again as shown by lipo). But, the final build is 'ppc970'.

I have gone over this very carefully to ensure I got everything. Can anyone think of a reason for the ppc architecture differences?

I've even gone so far as to create a new project (Hello World) and link it to all the libs and frameworks of the first project. Hello builds as 'ppc' not 'ppc970'.

This just makes no sense to me.

回答1:

ppc970 == G5. If you need to support as far back as the G4 then just build for ppc7400.

Rather than messing with individual architecture settings, though, you can just select 32-bit Universal (or Standard (32/64-bit Universal), if appropriate) from the popup menu, and that should give you what you need.



回答2:

In target settings make below changes..

GCC_MODEL_PPC64 = NO

i.e., uncheck “Use 64-bit integer Math”.

Enabling will turn on 64 bit. So it will be G5 onwards..