Mac OS X Build Prerequisites

  • Revision slug: Developer_Guide/Build_Instructions/Mac_OS_X_Prerequisites
  • Revision title: Mac OS X Build Prerequisites
  • Revision id: 22906
  • Created:
  • Creator: Sardisson
  • Is current revision? No
  • Comment /* Troubleshooting */ one more DP->MP change

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.

The CodeWarrior-based CFM build system is obsolete, and has not worked since Mozilla 1.3alpha.

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

{{wiki.template(':en/Build_Documentation/TOC')}}


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.3.9 or later. It is advisable to upgrade to the latest “point” release (currently 10.3.9 and 10.4.9) by running Software Update, found in the Apple menu. Mozilla will not build or run on 10.1 (“Puma”). 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”). Beginning with Mozilla 1.9 (the current trunk), Mac OS X 10.3 is required at runtime, too. 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 1.5 or later. Earlier versions of Xcode and Developer Tools are no longer supported. 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 recommended. 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.
    • Fink. You may download the most recent version of Fink that is compatible with your operating system release. Fink installs in /sw by default. The installer should configure the Fink environment for you, making it available in any new Terminal window. If you perform a major operating system upgrade on your computer, such as an upgrade from Jaguar to Panther, you should remove the /sw directory and re-install Fink and the packages below.
    • 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.
  • libIDL and GLib, libraries used by Mozilla’s IDL (interface definition language) file parser. These may be installed using a package manager. Administrative privileges are required, provide your password to the sudo command if requested.
    • Using Fink. libIDL is included in the ORBit installation.
      $ sudo apt-get update
      $ sudo apt-get install orbit orbit-dev glib
    • Using MacPorts (DarwinPorts). Installing libIDL also installs GLib.
      $ sudo port sync
      $ sudo port install libidl
  • The Shared Menus Cocoa Framework is only required to build Camino. Download the SharedMenusCocoa disk image, extracting it using StuffIt Expander if necessary, and copy the SharedMenusCocoa.framework folder from inside the SharedMenusCocoa/build folder to /Library/Frameworks. Be sure to look inside the SharedMenusCocoa folder and then inside the build folder to find SharedMenusCocoa.framework. If you copy another folder with a similar name instead, your Camino build will not succeed. See the detailed Camino-specific build instructions for more information, including additional steps required for Intel or Universal builds.
  • autoconf version 2.13 is only needed if you plan on making changes to the Mozilla configure scripts. Newer versions of autoconf, including those that are included with Xcode and installed in /usr/bin, are incompatible with Mozilla ({{template.Bug(104642)}}).
    • Using Fink. autoconf is installed at /sw/bin/autoconf. Do not install the autoconf2.5 or autoconf2.54 packages.
      $ sudo apt-get install autoconf
    • Using MacPorts (DarwinPorts). autoconf is installed at /opt/local/bin/autoconf213. 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.
      $ sudo port install autoconf213

.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, 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.

    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 PowerPC builds use /Developer/SDKs/MacOSX10.3.9.sdk on the trunk, and /Developer/SDKs/MacOSX10.2.8.sdk on the 1.8.0 and 1.8.1 branches. Note that there is no MacOSX10.3.9.sdk in Xcode 1.5 on Mac OS X 10.3, and if you are using Xcode 1.5, you will need to use MacOSX10.3.0.sdk instead.

    Official Intel builds have used and will continue to use /Developer/SDKs/MacOSX10.4u.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 troubleshooting section for a workaround.

    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 PowerPC builds on the trunk is 10.3; the 1.8.0 and 1.8.1 branches use 10.2. The default for Intel builds 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 a PowerPC version of Minefield (equivalent to Firefox) 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

    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

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 {{template.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 ~/.bashrc 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.
  • The build complains that some Shared Menus header is missing: Check that the SharedMenusCocoa.framework in installed in /Library/Frameworks, and that the symlinks inside the framework are OK.
  • 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.)

  • {{ wiki.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 (mark@moxienet.com),      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">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">building Mozilla as a universal binary</a>.
    </p><p>The <a class="external" href="http://www.mozilla.org/build/mac_cfm.html">CodeWarrior-based CFM build system</a> is obsolete, and has not worked since Mozilla 1.3alpha.
    </p><p>If you run into problems, see the <a href="en/Mozilla_Build_FAQ">Mozilla Build Frequently Asked Questions</a> or the rest of the <a href="en/Build_Documentation">Mozilla build documentation</a>.
    </p><p>{{wiki.template(':en/Build_Documentation/TOC')}}
    </p><p><br>
    </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> <b>Processor:</b> 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">Mac OS X Universal Binaries</a>).
    </li><li> <b>Memory:</b> 256MB RAM minimum, 1GB recommended.
    </li><li> <b>Disk Space:</b> 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> <b>Operating System:</b> Mac OS X 10.3.9 or later.  It is advisable to upgrade to the latest “point” release (currently 10.3.9 and 10.4.9) by running Software Update, found in the Apple menu.  Mozilla will not build or run on 10.1 (“Puma”).  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”).  Beginning with Mozilla 1.9 (the current trunk), Mac OS X 10.3 is required at runtime, too.  For additional details, see the <a class="external" href="http://wiki.mozilla.org/Mac:Build_Requirements#Compatibility_Matrix">Mac compatibility matrix</a>.
    </li></ul>
    <p>To install the following software requirements, you may need administrative privileges on the system.
    </p>
    <ul>
    <li><b>Development Environment:</b> <a class="external" href="http://developer.apple.com/tools/xcode/">Xcode Tools</a> 1.5 or later.  Earlier versions of Xcode and Developer Tools are no longer supported.  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 recommended.  These are selected by clicking the “Customize” button in the Xcode installer.  There are two ways to obtain or upgrade Xcode:</li>
    <ul>
    <li><i>Download:</i> <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><i>DVD or CD:</i> 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><b>Package Management:</b> 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><i><a class="external" href="http://fink.sourceforge.net/">Fink</a></i>.  You may <a class="external" href="http://fink.sourceforge.net/download/index.php">download</a> the most recent version of Fink that is compatible with your operating system release.  Fink installs in <code>/sw</code> by default.  The installer should configure the Fink environment for you, making it available in any new Terminal window.
    
    If you perform a major operating system upgrade on your computer, such as an upgrade from Jaguar to Panther, you should remove the <code>/sw</code> directory and re-install Fink and the packages below.
    </li>
    <li><i><a class="external" href="http://www.macports.org/">MacPorts</a></i>, formerly DarwinPorts. You may <a class="external" href="http://svn.macosforge.org/repository/macports/downloads/MacPorts-1.4.0/">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>
    </ul>
    <li><b><a class="external" href="http://andrewtv.org/libIDL/">libIDL</a></b> and <b><a class="external" href="http://www.gtk.org/">GLib</a></b>, libraries used by Mozilla’s IDL (interface definition language) file parser.  These may be installed using a package manager.  Administrative privileges are required, provide your password to the <code>sudo</code> command if requested.
    <ul>
    <li>Using <i>Fink</i>.  libIDL is included in the ORBit installation.
    <pre>$ sudo apt-get update
    $ sudo apt-get install orbit orbit-dev glib</pre></li>
    <li>Using <i>MacPorts</i> (DarwinPorts).  Installing libIDL also installs GLib.
    <pre>$ sudo port sync
    $ sudo port install libidl</pre></li>
    </ul></li>
    <li>The <b>Shared Menus Cocoa Framework</b> is only required to build <a class="external" href="http://www.caminobrowser.org/">Camino</a>. <a class="external" href="ftp://ftp.url-manager.com/pub/SharedMenusCocoa.dmg.bin">Download</a> the SharedMenusCocoa disk image, extracting it using <a class="external" href="http://www.stuffit.com/mac/expander/">StuffIt Expander</a> if necessary, and copy the <code>SharedMenusCocoa.framework</code> folder from inside the <code>SharedMenusCocoa/build</code> folder to <code>/Library/Frameworks</code>.  Be sure to look inside the <code>SharedMenusCocoa</code> folder and then inside the <code>build</code> folder to find <code>SharedMenusCocoa.framework</code>.  If you copy another folder with a similar name instead, your Camino build will not succeed.  See the detailed <a class="external" href="http://wiki.caminobrowser.org/Development:Building">Camino-specific build instructions</a> for more information, including additional steps required for Intel or Universal builds.</li>
    <li><b><a class="external" href="http://www.gnu.org/software/autoconf/">autoconf</a> version 2.13</b> is only needed if you plan on making changes to the Mozilla configure scripts.  Newer versions of autoconf, including those that are included with Xcode and installed in <code>/usr/bin</code>, are incompatible with Mozilla ({{template.Bug(104642)}}).</li>
    <ul>
    <li>Using <i>Fink</i>. autoconf is installed at <code>/sw/bin/autoconf</code>.  Do not install the <code>autoconf2.5</code> or <code>autoconf2.54</code> packages.
    <pre>$ sudo apt-get install autoconf</pre></li>
    <li>Using <i>MacPorts</i> (DarwinPorts).  autoconf is installed at <code>/opt/local/bin/autoconf213</code>.  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.
    <pre>$ sudo port install autoconf213</pre></li>
    </ul>
    </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">Configuring Build Options</a>.  For specific information on configuring to build a universal binary, see <a href="en/Mac_OS_X_Universal_Binaries">Mac OS X Universal Binaries</a>.
    </p>
    <ul>
    <li><b>Compiler:</b> If you are using Mac OS X 10.4 (“Tiger”) or later on PowerPC, 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.  <b>Intel builds must be produced with gcc 4.0</b> (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">cross-compile</a> for PPC.
    </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><b>Mac OS X SDK:</b> 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 <b>Cross Development</b> category in the installer’s <b>Customize</b> screen.
    
    <pre>ac_add_options --with-macos-sdk=/path/to/SDK</pre>
    <p>Official PowerPC builds use <code>/Developer/SDKs/MacOSX10.3.9.sdk</code> on the trunk, and <code>/Developer/SDKs/MacOSX10.2.8.sdk</code> on the 1.8.0 and 1.8.1 branches.  Note that there is no <code>MacOSX10.3.9.sdk</code> in Xcode 1.5 on Mac OS X 10.3, and if you are using Xcode 1.5, you will need to use <code>MacOSX10.3.0.sdk</code> instead.
    </p><p>Official Intel builds have used and will continue to use <code>/Developer/SDKs/MacOSX10.4u.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><b>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 <a href="#Troubleshooting">troubleshooting</a> section for a workaround.</b>
    </p>
    Use of an SDK is highly recommended, especially when building on Mac OS X 10.3 with Xcode 1.5.</li>
    <li><b>Deployment Target:</b> 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 PowerPC builds on the trunk is <code>10.3</code>; the 1.8.0 and 1.8.1 branches use <code>10.2</code>.  The default for Intel builds is <code>10.4</code>.  Official builds use these defaults.</li>
    <li><b><a class="external" href="http://developer.apple.com/releasenotes/DeveloperTools/Prebinding.html">Prebinding</a>:</b> 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><b>Sample <code>.mozconfig</code>:</b> This <code>.mozconfig</code> file is suitable to build a PowerPC version of Minefield (equivalent to Firefox) 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>:
    
    <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>
    <p>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:
    </p>
    <pre>. $topsrcdir/browser/config/mozconfig
    ac_add_options --with-macos-sdk=/Developer/SDKs/MacOSX10.4u.sdk
    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 <b>not</b> defined.  <code>XP_MAC</code> is obsolete and is slowly being removed from the source tree (see {{template.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><b>After installing Xcode 2.4, the build fails in <code>nsLookAndFeel.cpp</code> with:<br><code>error: `kThemeBrushAlternatePrimaryHighlightColor' undeclared (first use this function)</code>.</b>
    
    <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><b>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>.</b>
    <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><b>QuickTime SDK Update:</b> 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><b>Using <i>Fink,</i> you get <code>apt-get: command not found</code>.</b>
    <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><b>Using <i>MacPorts</i> (DarwinPorts), you get <code>port: command not found</code>.</b>
    <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>~/.bashrc</code> 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><b>Using Fink with Virex 7.2:</b> 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><b>The build stops while building <code>libwidget.rsrc</code> in <code>widget/src/mac</code></b>
    <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><b>The build complains about missing IDL headers:</b> 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><b>The build complains that some Shared Menus header is missing:</b> Check that the <code>SharedMenusCocoa.framework</code> in installed in <code>/Library/Frameworks</code>, and that the symlinks inside the framework are OK.</li>
    <li><b>Can't find <code>dlfcn.h</code> with error <code>nsTraceRefcnt.cpp:68: dlfcn.h: No such file or directory</code></b>
    <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="external" href="mailto:am2stewa@uwaterloo.ca">Alex Stewart</a> for helping us track this down.)</p>
    </li>
    
    <div class="noinclude">
    </div>
    {{ wiki.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" } ) }}
    Revert to this revision