Am 28.01.2009 um 22:59 schrieb Terry Lambert: On Jan 28, 2009, at 12:36 PM, Greg Parker wrote: On Jan 28, 2009, at 1:23 AM, email@hidden wrote:
I am trying to compile C sources on a MacBook with Mac OS X 10.5.6 and "XCode 3.0 Developer Tools for Mac OS X v10.5 Leopard" from the original MacBook installation media as well as "Mac OS X v10.3.9 Support" from the same source installed.
2.
To compile PPC binaries for Mac OS X 10.3.9 from the makefiles on the 10.5.6 MacBook I use:
CC=gcc-3.3
CFLAGS=-arch ppc
LDFLAGS=-arch ppc -macosx_version_min=10.3.9
I expect the result should run on PPC G3, G4, G5 Macs with 10.3.9 and later installed, but:
Starting this binary on a G3 Mac with 10.4.11 installed results in:
dyld: lazy symbol binding failed: Symbol not found: _getopt$UNIX2003
Referenced from: /tmp/testapp
Expected in: /usr/lib/libSystem.B.dylib
dyld: Symbol not found: _getopt$UNIX2003
Referenced from: /tmp/testapp
Expected in: /usr/lib/libSystem.B.dylib
Starting this binary on a G4 Mac with 10.3.9 installed results in:
dyld: /tmp/testapp Undefined symbols:
/tmp/testapp undefined reference to ___stderrp expected to be defined in /usr/lib/libSystem.B.dylib
Trace/BPT trap
You need to set `-mmacosx-version-min=10.3.9` for both compiling and linking. Specifically, _getopt$UNIX2003 is an artifact of the recent UNIX compliance changes, and ___stderrp is probably a change in the crt0/libc startup system which changes often. -mmacosx-version-min tells the compiler which crt0/libc system to use and whether to expect UNIX compliance, among other things.
This set of flags might work. (Note spelling, which differs from what you typed above.)
CC=gcc-3.3
CFLAGS=-arch ppc -mmacosx-version-min=10.3.9
LDFLAGS=-arch ppc -mmacosx-version-min=10.3.9
They can't work for what he wants to target, which appears to be "all PPC platforms back to 10.3.9 and all Intel platforms", because the compiler versions changed, and with them, the vtable linkages.
I have two makefiles to be used on Intel Macs: one to compile for PPC binaries valid for 10.3.9 up to 10.5 and another to compile for Intel binaries valid from 10.4 to 10.5. So I can use different compiler versions as required. In fact I have one additional makefile which I previously used on a 10.4.11 PBG3 to compile PPC binaries for 10.3.9 up to 10.5. This combination works as expected but I wanted to switch from the PowerBook to a MacBook to compile the sources.
For older SDKs, he will also need to use the "-iwithsysroot" option to select headers for the compilation and symbol sets for the linkages so that they don't depend on changes after that version shipped (this would be automatic with the SDK selection, if he were using XCode, which he isn't, which is why I pointed him at the gcc man page).
The MacOSX10.3.9.sdk is not installed for recent Leopard or XCode distributions.
The first version of the SDK that would work for both Intel and PPC was shipped in Inca and was the MacOSX10.4u.sdk (the "u" stands for "universal". When we shipped Intel, we change the version of the compiler required; you aren't going to be able to build for PPC and Intel with the same compiler version if you are building PPC that old. Given that Panther shipped in 2003, it's probably time to give up on supporting 10.3; 10.3.9 barely has a chance to run binaries created with the 10.4u SDK, as we explicitly retrofited compatibility stubs for both some of the $UNIX2003, and all of the 64 vs. 32 bit "long double" for PPC into the libSystem in 10.3.9 software update. 10.3.8 and before have little/no chance of running them, which was the primary reason for the update.
I have tried several different settings according to the suggestions from this list and from http://developer.apple.com/documentation/developertools/Conceptual/cross_development/Using/chapter_3_section_2.html#//apple_ref/doc/uid/20002000-1114311-BABGCAAB
Finally I got everything compiling as required:
4. settings to create the PPC binaries on the Intel Mac with Mac OS X 10.5.6 installed:
CC= MACOSX_DEPLOYMENT_TARGET=10.3 gcc LD= MACOSX_DEPLOYMENT_TARGET=10.3 gcc SDK=/Developer/SDKs/MacOSX10.3.9.sdk CFLAGS=-arch ppc -mmacosx-version-min=10.3.9 -isysroot ${SDK} LDFLAGS=-arch ppc -macosx_version_min=10.3.9 -isysroot ${SDK} -Wl,-syslibroot,${SDK} The binaries run on Mac OS X 10.3.9, 10.4 and 10.5, although some OS tools cannot handle them correctly, e.g. Unix command strings aborts as follows: /usr/bin/strings: object: testapp malformed object (unknown load command 7)
5. settings to create the Intel binaries on the Intel Mac with Mac OS X 10.5.6 installed:
CC=MACOSX_DEPLOYMENT_TARGET=10.4 gcc LD=MACOSX_DEPLOYMENT_TARGET=10.4 gcc CFLAGS=-mmacosx-version-min=10.4 LDFLAGS=-macosx_version_min=10.4
If they're is willing to do that, then they will want the following flags:
-isysroot /Developer/MacOSX10.4u.sdk \ -mmacos-version-min=10.4 \ -arch i386 \ -arch ppc
(this assumes that they did not take advantage of the ability of the new XCode to install itself into a non-standard location).
If they're not willing to do that, then the only alternative is to build separate PPC (on a 10.3.9 system) and Intel binaries, and lipo them together into a universal binary, which is not something I'm going to recommend by documenting how to do.
So I do compile the sources with all the same 10.4u gcc compiler in all cases. I am distributing separate binaries for PPC and for Intel.
|