Mac OS X Build Prerequisites

  • Revision slug: Developer_Guide/Build_Instructions/Mac_OS_X_Prerequisites
  • Revision title: Mac OS X Build Prerequisites
  • Revision id: 22957
  • Created:
  • Creator: GavinSharp
  • Is current revision? No
  • Comment 9 words added, 24 words removed

Revision Content

NOTE: substantive changes to this page (non-editorial) should be reviewed by Mark Mentovai (mark@moxienet.com), or one of the build-config peers

Mozilla builds for Mac OS X are Mach-O builds, built with gcc and Makefiles. Doing builds on Mac OS X is therefore very similar to doing Unix/Linux builds. You should be comfortable using the Terminal app (in /Applications/Utilities). Additional instructions are available for building Mozilla as a universal binary.

If you run into problems, see the Mozilla Build Frequently Asked Questions or the rest of the Mozilla build documentation.

{{ :en/Build_Documentation/TOC() }}

Firefox Quick Start

It only takes a few steps to get Mozilla building for most people, for most purposes. The other sections on this page go into more detail on complete build requirements for various Mozilla projects. These steps will get the most recent (trunk) version of Firefox built on Mac OS X 10.5.

1. Install Xcode Tools. Insert the "Mac OS X Install DVD" (which came with your computer), open the "Optional Installs" folder, then the "Xcode Tools" folder, and launch the XCodeTools installer. Alternatively, download the latest XCode from the ADC site (the version that comes on the DVD with late 2008 Macbook Pros, for example, has non-working profiling tools, e.g. Shark).

2. Install MacPorts. Go to their install page, download the .dmg for your platform, and install it.

Note: MacPorts 1.7 is fine, but due to a bug in MacPorts 1.6.0, it doesn't initialize your environment properly (resulting in errors like "port: command not found"). Add the following to the .profile (or .bash_profile or .bash_login, if either exists) file in your home directory, and restart Terminal.App to make the changes take effect:

export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH

3. Install packages needed for grabbing and building Firefox.

$ sudo port sync
$ sudo port install mercurial libidl autoconf213

This will ask for your root password and then take some time. Common errors include:

  • |sudo| doesn't accept a blank password: create a password for your account in System Preferences.
  • Errors while building Python. Try again and it should succeed the third time.
  • |port| command not found: add it to your path (see troubleshooting section below).
  • |port| invalid command name "use_parallel_build": update MacPorts to version >= 1.600 with 'sudo port selfupdate'.

Check that Mercurial works by typing:

$ hg version

If this fails with the error "ValueError: unknown locale: UTF-8", then see the workarounds on the Mercurial wiki's Unix Install page.

When trying to clone a repository you may get an HTTP 500 error (internal server errer). This seems to be due to something that Mac Mercurial sends to the server (it's been observed both with MacPort and selenic.com Mercurial binaries). Try restarting your shell, your computer, or reinstall Mercurial (in that order) then report back here what worked, please.

4. Create a file named .mozconfig in your home directory, with the following contents:

. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-ff-dbg
mk_add_options MOZ_MAKE_FLAGS="-s -j4"
ac_add_options --enable-debug
ac_add_options --disable-optimize
ac_add_options --with-macos-sdk=/Developer/SDKs/MacOSX10.4u.sdk

This will create a debug build of Firefox. For other options, see Configuring Build Options.

5. Get the Mozilla source.

For trunk, use Mercurial (hg):

$ hg clone http://hg.mozilla.org/mozilla-central/ mozilla
$ cd mozilla

For older versions such as Firefox 3.0.x, use CVS:

$ cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co mozilla/client.mk mozilla/browser/config/mozconfig
$ cd mozilla
$ make -f client.mk checkout

6. Build it.

$ make -f client.mk build

7. Launch your application. From the top directory, the application is at obj-ff/dist/Minefield.app or obj-ff/dist/MinefieldDebug.app. "Minefield" is the default build name of the "unbranded" Firefox executable that you have built. Note that you may not want to move the binary, as soft links inside the bundle will be wrong and the application might not launch. From the command-line, you can launch with (using the correct capitalization):

$ open obj-ff/dist/MinefieldDebug.app

 

Hardware Requirements

There are no specific hardware requirements, provided that the hardware accommodates all of the software required to build Mozilla. Mozilla can take a very long time to build, so recommended development systems are listed alongside the minimum requirements.

  • Processor: PowerPC G3 or later, PowerPC G5 or Intel CPUs recommended. Mozilla can now be built for either type of processor, or as a universal binary for both types (see Mac OS X Universal Binaries).
  • Memory: 256MB RAM minimum, 1GB recommended.
  • Disk Space: At least 1GB of free disk space for non-debug builds; development/debug builds require at least 2.5GB of free disk space.

Software Requirements

  • Operating System: Mac OS X 10.4.11 or later. It is advisable to upgrade to the latest “point” release (currently 10.4.11 and 10.5.6) by running Software Update, found in the Apple menu.
    • Beginning with Mozilla 1.9 (cvs trunk), Mac OS X 10.4 is both a build- and run-time requirement.
    • Mozilla’s 1.8.0 and 1.8.1 branches will run on Mac OS X 10.2 (“Jaguar”), but the build requires a minimum of 10.3 (“Panther”).
    • No recent version of Mozilla will build or run on 10.1 (“Puma”).
    • For additional details, see the Mac compatibility matrix.

To install the following software requirements, you may need administrative privileges on the system.

  • Development Environment: Xcode Tools 2.1 or later. Earlier versions of Xcode and Developer Tools are no longer supported (Xcode 1.5 is still supported on the Mozilla 1.8 and 1.8.0 branches). Xcode 2.0 is not recommended, but Xcode 2.1 and later work properly. Tested Xcode configurations are listed in the Mac compatibility matrix. Installing the cross-development environments (SDKs) is required; consult the Mac compatibility matrix to find the specific SDKs required for the branch(es) and product(s) you are building. These are selected by clicking the “Customize” button in the Xcode installer. There are two ways to obtain or upgrade Xcode:
    • Download: Download Xcode from Apple. This ensures that you’ll install the latest version of the tools available for your computer. You’ll need a (free) Apple Developer Connection membership. Note that Xcode updates are not installed by Software Update at this time.
    • DVD or CD: Most Macs and retail versions of Mac OS X include an Xcode installer on the installation discs. Check your discs for Xcode or Developer Tools.
  • Package Management: A package management system is not strictly required, but simplifies the installation of additional build dependencies. There are two package management systems that are compatible with the Mozilla build system, Fink and MacPorts (formerly DarwinPorts). Note that package installation may be a time-consuming but automated process using either tool.
    • MacPorts, formerly DarwinPorts. You may download the MacPorts installer corresponding to your operating system release. MacPorts installs in /opt/local by default. After running the MacPorts installer, the changes that it makes to the shell environment will be available in any new Terminal window.
    • fink (not recommended).
  • libIDL and GLib, libraries used by Mozilla’s IDL (interface definition language) file parser. These may be installed using MacPorts using the commands listed below. Glib is installed automatically as part of the libidl install. Administrative privileges are required, provide your password to the sudo command if requested:
    $ sudo port sync
    $ sudo port install libidl
  • autoconf version 2.13 is needed if you plan on making changes to the Mozilla configure.in files on versions up to 1.9 and when building from mozilla-central. Newer versions of autoconf, including those that come with Xcode and installed in /usr/bin, are incompatible with Mozilla ({{ Bug("104642") }}).
    $ sudo port install autoconf213

    The above commands install autoconf-2.13 to /opt/local/bin/autoconf213 using MacPorts. You will need to type autoconf213 to run it when other documentation might instruct you to run autoconf. Do not install the autoconf package without the 213 suffix.

    When building from mozilla-central, use mk_add_options AUTOCONF=autoconf213 in your .mozconfig

  • Mercurial source control system (if you're planning to work on post-1.9.0 code). See Mercurial#Installing.

.mozconfig Options and Other Tunables

These options are specific to Mozilla builds for Mac OS X. For a more general overview of build options and the .mozconfig file, see Configuring Build Options. For specific information on configuring to build a universal binary, see Mac OS X Universal Binaries.

  • Compiler: If you are using Mac OS X 10.4 (“Tiger”) or later on PowerPC and are working on the 1.8 branch or earlier, you should change the system default compiler to gcc 3.3, the compiler used to produce official PowerPC builds. Use the following command:
    $ sudo gcc_select 3.3

    As an alternative to changing the system default compiler, you may specify the compiler to use for a Mozilla build at configure time by setting the CC and CXX environment variables to select your desired C and C++ compilers. You can enter these commands in the Terminal before starting a Mozilla build, or you can place them in your .mozconfig file:

    export CC=gcc-3.3
    export CXX=g++-3.3

    Mozilla will build with gcc 4.0 (provided that Xcode 2.1 or later is installed), and some developers prefer this newer compiler. Applications built using gcc 4.0 will only run on Mac OS X 10.3.9 and later. Official Intel builds are produced with gcc 4.0. Intel builds must be produced with gcc 4.0 (Apple's gcc 3.3 cannot produce Intel binaries), but you can use gcc 3.3 on an Intel Mac to cross-compile for PPC. The current trunk (Mozilla 1.9) requires gcc 4.0 to build.

    Be aware that the gcc 3.3 compiler for Mac OS X at optimization level -O3 is unable to build Mozilla, and that any compiler with the -fast optimization mode selected on PowerPC will result in a build failure.

The following options, specified with ac_add_options, are lines that are intended to be added to your .mozconfig file.

  • Mac OS X SDK: This selects the version of the system headers and libraries to build against, ensuring that the product you build will be able to run on older systems with less complete APIs available. Selecting an SDK with this option overrides the default headers and libraries in /usr/include, /usr/lib, and /System/Library. Mac OS X SDKs are installed in /Developer/SDKs during the Xcode installation by selecting the Cross Development category in the installer’s Customize screen.
    ac_add_options --with-macos-sdk=/path/to/SDK

    Official trunk builds use /Developer/SDKs/MacOSX10.4u.sdk. On the 1.8.0 and 1.8.1 branches, official PowerPC builds use /Developer/SDKs/MacOSX10.2.8.sdk, while official Intel builds use /Developer/SDKs/MacOSX10.4u.sdk.
    Building with --enable-dtrace requires the 10.5 SDK: --with-macos-sdk=/Developer/SDKs/MacOSX10.5.sdk

    Note that some frameworks (notably AppKit) behave differently at runtime depending on which SDK was used at build time. This may be the source of bugs that only appear on certain platforms or in certain builds.

    You will not be able to build Mozilla using the 10.2.8 SDK included in the Xcode 2.4 installer. If you install Xcode 2.4, please see the {{ mediawiki.internal('#Troubleshooting|troubleshooting', "en") }} section for a workaround.Upgrade to Xcode 2.4.1 or newer.

    Use of an SDK is highly recommended, especially when building on Mac OS X 10.3 with Xcode 1.5.
  • Deployment Target: This option selects the minimum OS version that the resulting application will run on. Proper use of this option requires additional support in the code.
    ac_add_options --enable-macos-target=version
    This option is not recommended. The default for the trunk on all platforms is 10.4. The default for PowerPC builds on the 1.8.0 and 1.8.1 branches is 10.3, while the default for Intel builds on those branches is 10.4. Official builds use these defaults.
  • Prebinding: The Mozilla build system allows you to build an application and libraries that are prebound. This improves application launch time on Mac OS X 10.3.3 and earlier.
    ac_add_options --enable-prebinding
    The default is to not prebind. Official PowerPC builds are prebound. Official Intel builds are not prebound, as no Intel build will run on any release earlier than 10.4.
  • Sample .mozconfig: This .mozconfig file is suitable to build an Intel version of Minefield (equivalent to Firefox), which will only run on Intel-based Macs running Mac OS X 10.4 or newer:
    . $topsrcdir/browser/config/mozconfig
    ac_add_options --with-macos-sdk=/Developer/SDKs/MacOSX10.4u.sdk
    ac_add_options --disable-tests

    This .mozconfig file is suitable to build a PowerPC version of Minefield (equivalent to Firefox) from the Mozilla 1.8 and 1.8.0 branches able to run on the widest possible range of computers. This may be used on any PowerPC Mac meeting the software requirements:

    export CC=gcc-3.3
    export CXX=g++-3.3
    . $topsrcdir/browser/config/mozconfig
    ac_add_options --with-macos-sdk=/Developer/SDKs/MacOSX10.3.9.sdk
    ac_add_options --enable-prebinding
    ac_add_options --disable-tests

Build Defines

For Mac OS X builds, defines are set up as follows:

  • XP_MACOSX is defined
  • XP_UNIX is defined
  • XP_MAC is not defined. XP_MAC is obsolete and is slowly being removed from the source tree (see {{ Bug("281889") }}). It was used for CFM (non-Mach-O) builds for the classic (pre-X) Mac OS.

This requires care when writing code for Unix platforms that exclude Mac:

#if defined(XP_UNIX) && !defined(XP_MACOSX)

Troubleshooting

  • After installing Xcode 2.4, the build fails in nsLookAndFeel.cpp with:
    error: `kThemeBrushAlternatePrimaryHighlightColor' undeclared (first use this function).

    The 10.2.8 SDK included in Xcode 2.4 (build 8K1079) contains a bug that prevents Mozilla from building with that SDK. Apple has been notified of this bug, which is being tracked as Radar 4671592. This bug has been fixed as of Xcode 2.4.1.

  • After installing QuickTime 7.0.4 on Mac OS X 10.3.9, the build fails in libwidget_mac.dylib with:
    ld: /usr/lib/gcc/darwin/3.3/libstdc++.a(eh_personality.o) illegal reference to symbol: ___cxa_begin_catch defined in indirectly referenced dynamic library /usr/lib/libstdc++.6.dylib.

    To work around this conflict, you will need to use an SDK. Select the MacOSX10.2.8.sdk (recommended), or, if you must, you can also use MacOSX10.3.0.sdk. See the section on .mozconfig Options and Other Tunables for detailed instructions on using an SDK.

    Apple linked the QuickTime 7.0.4 framework against the shared libstdc++.6 library available in Mac OS X 10.3.9 and later, but the compiler (gcc 3.3) and build tools used on these systems do not expect to link against this library. gcc 3.3 expects to use its own statically-linked libstdc++. The QuickTime stub frameworks in the SDKs do not share this problem.

  • QuickTime SDK Update: If you install or update QuickTime 7, you may also need to install an updated QuickTime SDK, available from “Software Update” in the Apple menu. This update is only needed if Software Update indicates that it is available to you. You will need this update if your build fails because it is unable to find Sound.r.
  • Using Fink, you get apt-get: command not found.

    apt-get is not in your $PATH. Close and reopen Terminal and try again. If the error persists, Fink was unable to fully configure itself in your environment. Take these steps:

    • If you use the bash shell, the default since Mac OS X 10.3, edit your ~/.bashrc file, adding the following line. Don’t neglect the leading period and space.
      . /sw/bin/init.sh
    • If you use the tcsh shell, edit your ~/.tcshrc file, adding the following line:
      source /sw/bin/init.csh
    • After modifying the appropriate file, close and reopen Terminal and try again.
  • Using MacPorts (DarwinPorts), you get port: command not found.

    port is not in your $PATH. Close and reopen Terminal and try again. If the error persists, DarwinPorts was unable to fully configure itself in your environment. Take these steps:

    • If you use the bash shell, the default since Mac OS X 10.3, edit your ~/.profile (or ~/.bash_profile or ~/.bash_login, if either exists) file, adding the following line:
      export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
    • If you use the tcsh shell, edit your ~/.tcshrc file, adding the following line:
      setenv PATH "/opt/local/bin:/opt/local/sbin:$PATH"
    • After modifying the appropriate file, close and reopen Terminal and try again.
  • Using Fink with Virex 7.2: There is a conflict between Fink and Virex 7.2. Both place files within /sw. If you have Virex installed, you will need to upgrade to at least version 7.2.1, as described in the Fink News (2003-04-16).
  • The build stops while building libwidget.rsrc in widget/src/mac

    Delete, or rename ~/Library/Preferences/.GlobalPreferences.plist. We're not quite sure what setting in that file is causing this problem. Note that if you remove this file, system preferences such as preferred locales and recent programs will also disappear.

  • The build complains about missing IDL headers: Make sure you installed the orbit distribution via Fink's apt-get, and that you edited your .bashrc to source the /sw/bin/init.sh file or your .tcshrc file to source the /sw/bin/init.csh file.
  • Can't find dlfcn.h with error nsTraceRefcnt.cpp:68: dlfcn.h: No such file or directory

    Make sure you have the libdl.dylib from Fink. If you install bash from Apple, it will provide a copy of libdl.dylib which will not come with the headers (eg. dlfcn.h) needed to compile new programs that use the library, such as Mozilla. The solution is to remove the bash from Apple and install the bash from Fink. (Thanks to Alex Stewart for helping us track this down.)

  • Building with --enable-dtrace fails with configure: error: dtrace enabled but sys/sdt.h not found 

    Make sure you use the 10.5 SDK, not 10.4 as in the default configuration.

    {{ languages( { "es": "es/Requerimientos_para_la_compilaci\u00f3n_en_Mac_OS_X", "fr": "fr/Pr\u00e9alables_\u00e0_la_compilation_sous_Mac_OS_X", "ja": "ja/Mac_OS_X_Build_Prerequisites" } ) }}

    Revision Source

    <p><span class="comment">NOTE: substantive changes to this page (non-editorial) should be reviewed by Mark Mentovai <a class=" link-mailto" href="mailto:(mark@moxienet.com)" rel="freelink">(mark@moxienet.com)</a>, or one of the build-config peers</span></p>
    <p>Mozilla builds for Mac OS X are Mach-O builds, built with gcc and Makefiles. Doing builds on Mac OS X is therefore very similar to doing <a href="/en/Linux_Build_Prerequisites" title="en/Linux_Build_Prerequisites">Unix/Linux builds</a>. You should be comfortable using the Terminal app (in <code>/Applications/Utilities</code>). Additional instructions are available for <a href="/en/Mac_OS_X_Universal_Binaries" title="en/Mac_OS_X_Universal_Binaries">building Mozilla as a universal binary</a>.</p>
    <p>If you run into problems, see the <a href="/en/Mozilla_Build_FAQ" title="en/Mozilla_Build_FAQ">Mozilla Build Frequently Asked Questions</a> or the rest of the <a href="/en/Build_Documentation" title="en/Build_Documentation">Mozilla build documentation</a>.</p>
    <p>{{ :en/Build_Documentation/TOC() }}</p>
    <h3 name="Firefox_Quick_Start">Firefox Quick Start</h3>
    <p>It only takes a few steps to get Mozilla building for most people, for most purposes. The other sections on this page go into more detail on complete build requirements for various Mozilla projects. These steps will get the most recent (trunk) version of Firefox built on Mac OS X 10.5.</p>
    <p>1. Install Xcode Tools. Insert the "Mac OS X Install DVD" (which came with your computer), open the "Optional Installs" folder, then the "Xcode Tools" folder, and launch the XCodeTools installer. Alternatively, download the <a class="external" href="http://developer.apple.com/technology/xcode.html" title="http://developer.apple.com/technology/xcode.html">latest XCode</a> from the ADC site (the version that comes on the DVD with late 2008 Macbook Pros, for example, has non-working profiling tools, e.g. Shark).</p>
    <p>2. Install MacPorts. Go to their <a class="external" href="http://www.macports.org/install.php">install page</a>, download the <code>.dmg</code> for your platform, and install it.</p>
    <p style="margin-left: 40px;">Note: MacPorts 1.7 is fine, but due to a <a class="external" href="http://trac.macports.org/ticket/13742" title="http://trac.macports.org/ticket/13742">bug</a> in MacPorts 1.6.0, it doesn't initialize your environment properly (resulting in errors like "port: command not found"). Add the following to the <code>.profile</code> (or <code>.bash_profile</code> or <code>.bash_login</code>, if either exists) file in your home directory, and restart Terminal.App to make the changes take effect:</p>
    <pre class="eval" style="margin-left: 40px;">export PATH=/opt/local/bin:/opt/local/sbin:$PATH
    export MANPATH=/opt/local/share/man:$MANPATH</pre>
    <p>3. Install packages needed for grabbing and building Firefox.</p>
    <pre class="eval" style="margin-left: 40px;">$ sudo port sync
    $ sudo port install mercurial libidl autoconf213
    </pre>
    <p>This will ask for your root password and then take some time. Common errors include:</p>
    <ul> <li>|sudo| doesn't accept a blank password: create a password for your account in System Preferences.</li> <li><a class="external" href="http://trac.macports.org/ticket/13930">Errors while building Python</a>. Try again and it should succeed the <em>third</em> time.</li> <li>|port| command not found: add it to your path (see troubleshooting section below).</li> <li>|port| invalid command name "use_parallel_build": update MacPorts to version &gt;= 1.600 with 'sudo port selfupdate'.</li>
    </ul>
    <p>Check that Mercurial works by typing:</p>
    <pre class="eval" style="margin-left: 40px;">$ hg version
    </pre>
    <p>If this fails with the error "ValueError: unknown locale: UTF-8", then see the <a class="external" href="http://www.selenic.com/mercurial/wiki/index.cgi/UnixInstall#head-1c10f216d5b9ccdcb2613ea37d407eb45f22a394" title="http://www.selenic.com/mercurial/wiki/index.cgi/UnixInstall#head-1c10f216d5b9ccdcb2613ea37d407eb45f22a394">workarounds</a> on the Mercurial wiki's Unix Install page.</p>
    <p>When trying to clone a repository you may get an HTTP 500 error (internal server errer). This seems to be due to something that Mac Mercurial sends to the server (it's been observed both with MacPort and selenic.com Mercurial binaries). Try restarting your shell, your computer, or reinstall Mercurial (in that order) then report back here what worked, please.</p>
    <p>4. Create a file named <code>.mozconfig</code> in your home directory, with the following contents:</p>
    <pre class="eval">. $topsrcdir/browser/config/mozconfig
    mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-ff-dbg
    mk_add_options MOZ_MAKE_FLAGS="-s -j4"
    ac_add_options --enable-debug
    ac_add_options --disable-optimize
    ac_add_options --with-macos-sdk=/Developer/SDKs/MacOSX10.4u.sdk
    </pre>
    <p>This will create a debug build of Firefox. For other options, see <a href="/en/Configuring_Build_Options" title="en/Configuring_Build_Options">Configuring Build Options</a>.</p>
    <p>5. Get the Mozilla source.</p>
    <p>For trunk, use Mercurial (hg):</p>
    <pre class="eval">$ hg clone <a class=" external" href="http://hg.mozilla.org/mozilla-central/" rel="freelink">http://hg.mozilla.org/mozilla-central/</a> mozilla
    $ cd mozilla</pre>
    <p>For older versions such as Firefox 3.0.x, use CVS:</p>
    <pre class="eval">$ cvs -d <a class=" link-mailto" href="mailto::pserver:anonymous@cvs-mirror.mozilla.org" rel="freelink">:pserver:anonymous@cvs-mirror.mozilla.org</a>:/cvsroot co mozilla/client.mk mozilla/browser/config/mozconfig
    $ cd mozilla
    $ make -f client.mk checkout
    </pre>
    <p>6. Build it.</p>
    <pre class="eval">$ make -f client.mk build
    </pre>
    <p>7. Launch your application. From the top directory, the application is at obj-ff/dist/Minefield.app or obj-ff/dist/MinefieldDebug.app. "Minefield" is the default build name of the "unbranded" Firefox executable that you have built. Note that you may not want to move the binary, as soft links inside the bundle will be wrong and the application might not launch. From the command-line, you can launch with (using the correct capitalization):</p>
    <pre>$ open obj-ff/dist/MinefieldDebug.app
    </pre>
    <p> </p>
    <h3 name="Hardware_Requirements">Hardware Requirements</h3>
    <p>There are no specific hardware requirements, provided that the hardware accommodates all of the <a href="#Software_Requirements">software</a> required to build Mozilla. Mozilla can take a very long time to build, so recommended development systems are listed alongside the minimum requirements.</p>
    <ul> <li><strong>Processor:</strong> PowerPC G3 or later, PowerPC G5 or Intel CPUs recommended. Mozilla can now be built for either type of processor, or as a universal binary for both types (see <a href="/en/Mac_OS_X_Universal_Binaries" title="en/Mac_OS_X_Universal_Binaries">Mac OS X Universal Binaries</a>).</li> <li><strong>Memory:</strong> 256MB RAM minimum, 1GB recommended.</li> <li><strong>Disk Space:</strong> At least 1GB of free disk space for non-debug builds; development/debug builds require at least 2.5GB of free disk space.</li>
    </ul>
    <h3 name="Software_Requirements">Software Requirements</h3>
    <ul> <li><strong>Operating System:</strong> Mac OS X 10.4.11 or later. It is advisable to upgrade to the latest “point” release (currently 10.4.11 and 10.5.6) by running Software Update, found in the Apple menu. <ul> <li>Beginning with Mozilla 1.9 (cvs trunk), Mac OS X 10.4 is both a build- and run-time requirement.</li> <li>Mozilla’s 1.8.0 and 1.8.1 branches will run on Mac OS X 10.2 (“Jaguar”), but the build requires a minimum of 10.3 (“Panther”).</li> <li>No recent version of Mozilla will build or run on 10.1 (“Puma”).</li> <li>For additional details, see the <a class="external" href="http://wiki.mozilla.org/Mac:Build_Requirements#Compatibility_Matrix">Mac compatibility matrix</a>.</li> </ul> </li>
    </ul>
    <p>To install the following software requirements, you may need administrative privileges on the system.</p>
    <ul> <li><strong>Development Environment:</strong> <a class="external" href="http://developer.apple.com/tools/xcode/">Xcode Tools</a> 2.1 or later. Earlier versions of Xcode and Developer Tools are no longer supported (Xcode 1.5 is still supported on the Mozilla 1.8 and 1.8.0 branches). Xcode 2.0 is not recommended, but Xcode 2.1 and later work properly. Tested Xcode configurations are listed in the <a class="external" href="http://wiki.mozilla.org/Mac:Build_Requirements#Compatibility_Matrix">Mac compatibility matrix</a>. Installing the cross-development environments (SDKs) is required; consult the <a class="external" href="http://wiki.mozilla.org/Mac:Build_Requirements#Compatibility_Matrix">Mac compatibility matrix</a> to find the specific SDKs required for the branch(es) and product(s) you are building. These are selected by clicking the “Customize” button in the Xcode installer. There are two ways to obtain or upgrade Xcode:</li> <ul> <li><em>Download:</em> <a class="external" href="http://developer.apple.com/tools/download/">Download Xcode</a> from Apple. This ensures that you’ll install the latest version of the tools available for your computer. You’ll need a (free) <a class="external" href="http://connect.apple.com/">Apple Developer Connection</a> membership. Note that Xcode updates are not installed by Software Update at this time.</li> <li><em>DVD or CD:</em> Most Macs and retail versions of Mac OS X include an Xcode installer on the installation discs. Check your discs for Xcode or Developer Tools.</li> </ul> <li><strong>Package Management:</strong> A package management system is not strictly required, but simplifies the installation of additional build dependencies. There are two package management systems that are compatible with the Mozilla build system, Fink and MacPorts (formerly DarwinPorts). Note that package installation may be a time-consuming but automated process using either tool.</li> <ul> <li><em><a class="external" href="http://www.macports.org/">MacPorts</a></em>, formerly DarwinPorts. You may <a class="external" href="http://www.macports.org/install.php">download</a> the MacPorts installer corresponding to your operating system release. MacPorts installs in <code>/opt/local</code> by default. After running the MacPorts installer, the changes that it makes to the shell environment will be available in any new Terminal window.</li> <li><a href="/en/Mac_OS_X_Build_Prerequisites//fink" title="en/Mac_OS_X_Build_Prerequisites//fink">fink</a> (not recommended).</li> </ul> <li><strong><a class="external" href="http://andrewtv.org/libIDL/">libIDL</a></strong> and <strong><a class="external" href="http://www.gtk.org/">GLib</a></strong>, libraries used by Mozilla’s IDL (interface definition language) file parser. These may be installed using MacPorts using the commands listed below. Glib is installed automatically as part of the libidl install. Administrative privileges are required, provide your password to the <code>sudo</code> command if requested: <pre>$ sudo port sync
    $ sudo port install libidl</pre> </li> <li><strong><a class="external" href="http://www.gnu.org/software/autoconf/">autoconf</a> version 2.13</strong> is needed if you plan on making changes to the Mozilla configure.in files on versions up to 1.9 and when <a href="/en/Mozilla_Source_Code_(Mercurial)" title="en/Mozilla_Source_Code_(Mercurial)">building from mozilla-central</a>. Newer versions of autoconf, including those that come with Xcode and installed in <code>/usr/bin</code>, are incompatible with Mozilla ({{ Bug("104642") }}). <pre>$ sudo port install autoconf213</pre> <p>The above commands install autoconf-2.13 to <code>/opt/local/bin/autoconf213</code> using MacPorts. You will need to type <code>autoconf213</code> to run it when other documentation might instruct you to run <code>autoconf</code>. Do not install the <code>autoconf</code> package without the <code>213</code> suffix.</p> <p>When building from <a href="/en/mozilla-central" title="en/mozilla-central">mozilla-central</a>, use <code>mk_add_options AUTOCONF=autoconf213</code> in your .mozconfig</p> </li> <li><strong><a href="/en/Mercurial" title="en/Mercurial">Mercurial</a> source control system</strong> (if you're planning to work on post-1.9.0 code). See <a href="/en/Mercurial#Installing" title="en/Mercurial#Installing">Mercurial#Installing</a>.</li>
    </ul>
    <h3 name=".mozconfig_Options_and_Other_Tunables">.mozconfig Options and Other Tunables</h3>
    <p>These options are specific to Mozilla builds for Mac OS X. For a more general overview of build options and the <code>.mozconfig</code> file, see <a href="/en/Configuring_Build_Options" title="en/Configuring_Build_Options">Configuring Build Options</a>. For specific information on configuring to build a universal binary, see <a href="/en/Mac_OS_X_Universal_Binaries" title="en/Mac_OS_X_Universal_Binaries">Mac OS X Universal Binaries</a>.</p>
    <ul> <li><strong>Compiler:</strong> If you are using Mac OS X 10.4 (“Tiger”) or later on PowerPC and are working on the 1.8 branch or earlier, you should change the system default compiler to gcc 3.3, the compiler used to produce official PowerPC builds. Use the following command: <pre>$ sudo gcc_select 3.3</pre> <p>As an alternative to changing the system default compiler, you may specify the compiler to use for a Mozilla build at configure time by setting the <code>CC</code> and <code>CXX</code> environment variables to select your desired C and C++ compilers. You can enter these commands in the Terminal before starting a Mozilla build, or you can place them in your <code>.mozconfig</code> file:</p> <pre>export CC=gcc-3.3
    export CXX=g++-3.3</pre> <p>Mozilla will build with gcc 4.0 (provided that Xcode 2.1 or later is installed), and some developers prefer this newer compiler. Applications built using gcc 4.0 will only run on Mac OS X 10.3.9 and later. Official Intel builds are produced with gcc 4.0. <strong>Intel builds must be produced with gcc 4.0</strong> (Apple's gcc 3.3 cannot produce Intel binaries), but you can use gcc 3.3 on an Intel Mac to <a href="/en/Mac_OS_X_Universal_Binaries#Cross-Compilation" title="en/Mac_OS_X_Universal_Binaries#Cross-Compilation">cross-compile</a> for PPC. The current trunk (Mozilla 1.9) requires gcc 4.0 to build.</p> Be aware that the gcc 3.3 compiler for Mac OS X at optimization level <code>-O3</code> is unable to build Mozilla, and that any compiler with the <code>-fast</code> optimization mode selected on PowerPC will result in a build failure.</li>
    </ul>
    <p>The following options, specified with <code>ac_add_options</code>, are lines that are intended to be added to your <code>.mozconfig</code> file.</p>
    <ul> <li><strong>Mac OS X SDK:</strong> This selects the version of the system headers and libraries to build against, ensuring that the product you build will be able to run on older systems with less complete APIs available. Selecting an SDK with this option overrides the default headers and libraries in <code>/usr/include</code>, <code>/usr/lib</code>, and <code>/System/Library</code>. Mac OS X SDKs are installed in <code>/Developer/SDKs</code> during the <a href="#Software_Requirements">Xcode installation</a> by selecting the <strong>Cross Development</strong> category in the installer’s <strong>Customize</strong> screen. <pre>ac_add_options --with-macos-sdk=/path/to/SDK</pre> <p>Official trunk builds use <code>/Developer/SDKs/MacOSX10.4u.sdk</code>. On the 1.8.0 and 1.8.1 branches, official PowerPC builds use <code>/Developer/SDKs/MacOSX10.2.8.sdk</code>, while official Intel builds use <code>/Developer/SDKs/MacOSX10.4u.sdk</code>.<br> Building with <a class="internal" href="/en/DTrace" title="En/DTrace">--enable-dtrace</a> requires the 10.5 SDK: <code>--with-macos-sdk=/Developer/SDKs/MacOSX10.5.sdk</code></p> <p>Note that some frameworks (notably AppKit) behave differently at runtime depending on which SDK was used at build time. This may be the source of bugs that only appear on certain platforms or in certain builds.</p> <p><strong>You will not be able to build Mozilla using the 10.2.8 SDK included in the Xcode 2.4 installer. <span class="comment">If you install Xcode 2.4, please see the {{ mediawiki.internal('#Troubleshooting|troubleshooting', "en") }} section for a workaround.</span>Upgrade to Xcode 2.4.1 or newer.</strong></p> Use of an SDK is highly recommended, especially when building on Mac OS X 10.3 with Xcode 1.5.</li> <li><strong>Deployment Target:</strong> This option selects the minimum OS version that the resulting application will run on. Proper use of this option requires additional support in the code. <pre>ac_add_options --enable-macos-target=version</pre> This option is not recommended. The default for the trunk on all platforms is <code>10.4</code>. The default for PowerPC builds on the 1.8.0 and 1.8.1 branches is <code>10.3</code>, while the default for Intel builds on those branches is <code>10.4</code>. Official builds use these defaults.</li> <li><strong><a class="external" href="http://developer.apple.com/releasenotes/DeveloperTools/Prebinding.html">Prebinding</a>:</strong> The Mozilla build system allows you to build an application and libraries that are prebound. This improves application launch time on Mac OS X 10.3.3 and earlier. <pre>ac_add_options --enable-prebinding</pre> The default is to not prebind. Official PowerPC builds are prebound. Official Intel builds are not prebound, as no Intel build will run on any release earlier than 10.4.</li> <li><strong>Sample <code>.mozconfig</code>:</strong> This <code>.mozconfig</code> file is suitable to build an Intel version of Minefield (equivalent to Firefox), which will only run on Intel-based Macs running Mac OS X 10.4 or newer: <pre>. $topsrcdir/browser/config/mozconfig
    ac_add_options --with-macos-sdk=/Developer/SDKs/MacOSX10.4u.sdk
    ac_add_options --disable-tests</pre> <p>This <code>.mozconfig</code> file is suitable to build a PowerPC version of Minefield (equivalent to Firefox) from the Mozilla 1.8 and 1.8.0 branches able to run on the widest possible range of computers. This may be used on any PowerPC Mac meeting the <a href="#Software_Requirements">software requirements</a>:</p> <pre>export CC=gcc-3.3
    export CXX=g++-3.3
    . $topsrcdir/browser/config/mozconfig
    ac_add_options --with-macos-sdk=/Developer/SDKs/MacOSX10.3.9.sdk
    ac_add_options --enable-prebinding
    ac_add_options --disable-tests</pre> </li>
    </ul>
    <h3 name="Build_Defines">Build Defines</h3>
    <p>For Mac OS X builds, defines are set up as follows:</p>
    <ul> <li><code>XP_MACOSX</code> is defined</li> <li><code>XP_UNIX</code> is defined</li> <li><code>XP_MAC</code> is <strong>not</strong> defined. <code>XP_MAC</code> is obsolete and is slowly being removed from the source tree (see {{ Bug("281889") }}). It was used for CFM (non-Mach-O) builds for the classic (pre-X) Mac OS.</li>
    </ul>
    <p>This requires care when writing code for Unix platforms that exclude Mac:</p>
    <pre>#if defined(XP_UNIX) &amp;&amp; !defined(XP_MACOSX)</pre>
    <h3 name="Troubleshooting">Troubleshooting</h3>
    <ul> <li><strong>After installing Xcode 2.4, the build fails in <code>nsLookAndFeel.cpp</code> with:<br> <code>error: `kThemeBrushAlternatePrimaryHighlightColor' undeclared (first use this function)</code>.</strong> <p>The 10.2.8 SDK included in Xcode 2.4 (build 8K1079) contains a bug that prevents Mozilla from building with that SDK. Apple has been notified of this bug, which is being tracked as Radar 4671592. This bug has been fixed as of Xcode 2.4.1.</p> </li> <li><strong>After installing QuickTime 7.0.4 on Mac OS X 10.3.9, the build fails in <code>libwidget_mac.dylib</code> with:<br> <code>ld: /usr/lib/gcc/darwin/3.3/libstdc++.a(eh_personality.o) illegal reference to symbol: ___cxa_begin_catch defined in indirectly referenced dynamic library /usr/lib/libstdc++.6.dylib</code>.</strong> <p>To work around this conflict, you will need to use an SDK. Select the <code>MacOSX10.2.8.sdk</code> (recommended), or, if you must, you can also use <code>MacOSX10.3.0.sdk</code>. See the section on <a href="#.mozconfig_Options_and_Other_Tunables">.mozconfig Options and Other Tunables</a> for detailed instructions on using an SDK.</p> <p>Apple linked the QuickTime 7.0.4 framework against the shared libstdc++.6 library available in Mac OS X 10.3.9 and later, but the compiler (gcc 3.3) and build tools used on these systems do not expect to link against this library. gcc 3.3 expects to use its own statically-linked libstdc++. The QuickTime stub frameworks in the SDKs do not share this problem.</p> </li> <li><strong>QuickTime SDK Update:</strong> If you install or update QuickTime 7, you may also need to install an updated QuickTime SDK, available from “Software Update” in the Apple menu. This update is only needed if Software Update indicates that it is available to you. You will need this update if your build fails because it is unable to find <code>Sound.r</code>.</li> <li><strong>Using <em>Fink,</em> you get <code>apt-get: command not found</code>.</strong> <p><code>apt-get</code> is not in your <code>$PATH</code>. Close and reopen Terminal and try again. If the error persists, Fink was unable to fully configure itself in your environment. Take these steps:</p> <ul> <li>If you use the <code>bash</code> shell, the default since Mac OS X 10.3, edit your <code>~/.bashrc</code> file, adding the following line. Don’t neglect the leading period and space. <pre>. /sw/bin/init.sh</pre> </li> <li>If you use the <code>tcsh</code> shell, edit your <code>~/.tcshrc</code> file, adding the following line: <pre>source /sw/bin/init.csh</pre> </li> After modifying the appropriate file, close and reopen Terminal and try again.</ul> </li> </ul> <li><strong>Using <em>MacPorts</em> (DarwinPorts), you get <code>port: command not found</code>.</strong> <p><code>port</code> is not in your <code>$PATH</code>. Close and reopen Terminal and try again. If the error persists, DarwinPorts was unable to fully configure itself in your environment. Take these steps:</p> <ul> <li>If you use the <code>bash</code> shell, the default since Mac OS X 10.3, edit your <code>~/.profile</code> (or <code>~/.bash_profile</code> or <code>~/.bash_login</code>, if either exists) file, adding the following line: <pre>export PATH="/opt/local/bin:/opt/local/sbin:$PATH"</pre> </li> <li>If you use the <code>tcsh</code> shell, edit your <code>~/.tcshrc</code> file, adding the following line: <pre>setenv PATH "/opt/local/bin:/opt/local/sbin:$PATH"</pre> </li> After modifying the appropriate file, close and reopen Terminal and try again.</ul> </li> <li><strong>Using Fink with Virex 7.2:</strong> There is a conflict between Fink and Virex 7.2. Both place files within <code>/sw</code>. If you have Virex installed, you will need to upgrade to at least version 7.2.1, as described in the <a class="external" href="http://fink.sourceforge.net/news/index.php#2003-04-16%20Virex%20problem%20resolved">Fink News (2003-04-16)</a>.</li> <li><strong>The build stops while building <code>libwidget.rsrc</code> in <code>widget/src/mac</code></strong> <p>Delete, or rename <code>~/Library/Preferences/.GlobalPreferences.plist</code>. We're not quite sure what setting in that file is causing this problem. Note that if you remove this file, system preferences such as preferred locales and recent programs will also disappear.</p> </li> <li><strong>The build complains about missing IDL headers:</strong> Make sure you installed the orbit distribution via Fink's <code>apt-get</code>, and that you edited your <code>.bashrc</code> to source the <code>/sw/bin/init.sh</code> file or your <code>.tcshrc</code> file to source the <code>/sw/bin/init.csh</code> file.</li> <li><strong>Can't find <code>dlfcn.h</code> with error <code>nsTraceRefcnt.cpp:68: dlfcn.h: No such file or directory</code></strong> <p>Make sure you have the libdl.dylib from Fink. If you install <a class="external" href="http://www.apple.com/downloads/macosx/unix_apps_utilities/bashthegnubourneagainshell.html">bash from Apple</a>, it will provide a copy of libdl.dylib which will not come with the headers (eg. dlfcn.h) needed to compile new programs that use the library, such as Mozilla. The solution is to remove the bash from Apple and install the bash from Fink. (Thanks to <a class="link-mailto" href="mailto:am2stewa@uwaterloo.ca">Alex Stewart</a> for helping us track this down.)</p> </li> <p><strong>Building with --enable-dtrace fails with </strong><a class="external" href="/fckeditor.html?InstanceName=editarea&amp;Toolbar=Default" id="bkmk_href_" title="https://developer.mozilla.org/editor/fckeditor/core/editor/fckeditor.html?InstanceName=editarea&amp;Toolbar=Default"><strong>configure: error: dtrace enabled but sys/sdt.h not found</strong></a><strong> </strong></p> <p>Make sure you use the 10.5 SDK, not 10.4 as in the default configuration.</p> <p>{{ languages( { "es": "es/Requerimientos_para_la_compilaci\u00f3n_en_Mac_OS_X", "fr": "fr/Pr\u00e9alables_\u00e0_la_compilation_sous_Mac_OS_X", "ja": "ja/Mac_OS_X_Build_Prerequisites" } ) }}</p>
    Revert to this revision