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 03:47:14 -0800
On Jan 28, 2009, at 1:23 AM, email@hidden wrote:
Hi all,
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.
1.
To compile Intel binaries from the makefiles on the 10.5.6 MacBook I
use:
CC=gcc
CFLAGS=
LDFLAGS=
The results are as expected and the binaries can be launched on
Intel Macs.
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
3.
Compiling the same makefile from 2. on a G3 Mac OS X 10.4.11
produces binaries which can be run on PPC G3, G4 and G5 as expected.
What am I doing wrong in approach 2?
Failing to set -mmacos-version-min, as described in the gcc man page,
or Mac OS X Deployment Target, if you are using XCodes build system.
Also be aware that older versions of the SDK aren't shipped with
current versions of XCode, so you need to have installed them
previously and not erased your install.
What does the dyld messages mean?
The _getopt$UNIX2003 means you are using a new compilation environment
and trying to run the resulting code on a machine that doesn't support
that environment at runtime.
The __stderrp means you used a newer header file that defined struct
FILE for stderr as an indirect pointer that doesn't exist in the older
libSystem.
As a general class of error, these things can be a result of the
headers you include because you are using the wrong SDK to get
backward compatible code, it can be a result of using the wrong
compilation environment (see block comments in /usr/include/system/
cdefs.h, as well as the man page noted above), using new interfaces in
your code that simply don't exist on older versions of the OS (rather
than using runtime bindings to make the features optional, or some
combination of the three.
What do I need to do in order to compile on the Intel 10.5.6 machine
for all PPC processors and Mac OS X versions 10.3.9 and 10.4.11?
The easiest thing to do would be to go to <http://
developer.apple.com>, search for "Mac OS X Deployment Target", and
read the documentation that shows up in the first couple of results.
-- 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