Re: Compiling for all OS X versions
Re: Compiling for all OS X versions
- Subject: Re: Compiling for all OS X versions
- From: Terry Lambert <email@hidden>
- Date: Wed, 28 Jan 2009 13:59:19 -0800
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.
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.
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.
-- Terry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden