Mac OS X 平台的构建前提条件


没有特别的硬件要求, 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.


  • 操作系统: Mac OS X 10.3.9或更高,建议升级到最新的发行版本(当前为10.3.9与10.4.8),可以通过运行苹果菜单中的软件来升级。Mozilla不能在10.1(“Puma”)中生成或运行。Mozilla的1.8.0与1.8.1分支版本可以在Mac OS X 10.2(“Jaguar”)中运行,但是至少需要在10.3(“Panther”)中生成。Beginning with Mozilla 1.9 (the current trunk), Mac OS X 10.3 is required at runtime, too.更多的细节,请参考Mac兼容列表.


  • 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 DarwinPorts (MacPorts). 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.
    • DarwinPorts , from the OpenDarwin project, soon to be renamed MacPorts. You may download the DarwinPorts installer corresponding to your operating system release. DarwinPorts installs in /opt/local by default. After running the DarwinPorts 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 DarwinPorts (MacPorts). 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.
  • 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 (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 DarwinPorts (MacPorts). 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


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 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)


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. Apple has fixed as of Xcode 2.4.1.</li>

  • After installing Xcode 2.4, the build fails in nsLookAndFeel.cpp with:
    error: `kThemeBrushAlternatePrimaryHighlightColor' undeclared (first use this function).
  • 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.
    <p>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/
    • 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 DarwinPorts (MacPorts), 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/ 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.)


 此页面的贡献者: ziyunfei, Sheppy, Brilliance.liu
 最后编辑者: ziyunfei,