The Mac OS X Developer Tools are available from Apple and provide a development environment that will be familiar to any Unix developer whoworks with command-line compilers. For details about obtaining these tools, see the "Developer Tools" section in the Preface. The Developer Tools include all sorts of other goodies, including an advanced Integrated Development Environment (IDE), but coverage of those tools is beyond the scope and intent of this book. To learn more about the Developer Tools, you can see /Developer/Documentation/DeveloperTools/devtools.html. You can also learn how to use Project Builder and Interface Builder and how to program Cocoa applications with Objective-C in Learning Cocoa with Objective-C (O'Reilly) and Building Cocoa Applications: A Step-by-Step Guide (O'Reilly).
The C compiler that comes with the Developer Tools is based on the Free Software Foundation's GNU Compiler Collection, or GCC. Apple's modifications to GCC include the addition of Objective-C to the compiler suite, as well as various modifications to deal with the Darwin operating system. The development environment in Mac OS X includes:
TIP: You can also access the documentation for GCC with your web browser by going to /Developer/Documentation/DeveloperTools/Compiler/CompilerTOC.html.
We will not address the complete Mac OS X development suite in this chapter. Instead, we will focus on the command-line development tools and how they differ from the implementations on other Unix platforms.
Java programmers will find that the Mac OS X command-line Java tools (see Section 1.6.4) behave as they do under Unix and Linux.
Perl programmers coming from previous Macintosh systems will find that Mac OS X does not use MacPerl (http://www.macperl.com), but instead, uses the standard Unix build of the core Perl distribution (http://www.perl.org).
GCC is supported on a wide range of platforms and is familiar to most Unix developers. A natural consequence of this is that most Unix developers will find a familiar development environment in Mac OS X. There are, however, some important differences.
One difference that experienced GCC users may notice, particularly if they have dealt with a lot of mathematical and scientific programming, is that Mac OS X's Developer Tools do not include FORTRAN. However, the Fink distribution (http://fink.sourceforge.net) includes g77 , the GNU FORTRAN '77 compiler. Also, the Darwin archive includes the source code for g77, which you can use to compile FORTRAN code. For more information on the Darwin CVS archive, see Chapter 7.
TIP: Mac OS X's C compiler contains a number of Mac OS X-specific features that have not been folded into the main GCC distribution. (It is up to the Free Software Foundation (FSF) to accept and merge Apple's patches.) For information on how Apple's compiler differs from the GNU version, see the README.Apple file in the Darwin CVS archive's gcc3 subdirectory.
As of this writing, Apple's cc compiler is based on GCC 3.1. However, GCC 2.95 is also available as /usr/bin/gcc2. By default, invoking cc or gcc will invoke GCC 3.1. You can change this to GCC 2.95 by running the command gcc_select 2, and you can change it back with gcc_select 3. You can see the current settings by running gcc_select with no arguments:
% gcc_select Apple Computer, Inc. GCC version 1161, based on gcc version 3.1 20020420 (prerelease)
TIP: You can find the Mac OS X Compiler Release Notes on your system at /Developer/Documentation/ReleaseNotes/Compiler.html. You should consult these release notes for details on the most current known problems, issues, and features.
The Motorola AltiVec Velocity Engine is also supported for G4 processors by the Mac OS X GCC implementation. The compiler flag -faltivec must be specified to compile code engineered to use the Velocity Engine. Inclusion of this command-line option to cc defines the preprocessor symbol _ _VEC_ _.
Copyright © 2003 O'Reilly & Associates. All rights reserved.