This page covers the steps needed to prepare your machine to build a bleeding-edge, development version of Firefox and/or Thunderbird on Windows.
The Firefox build process is both I/O- and CPU-intensive, and can take a long time to build even on modern hardware. Minimum and recommended hardware requirements for Mozilla development are:
- At least 2 GB of RAM. 8 GB or more is recommended, and more is always better.
- 35 GB free disk space. This will accomodate Visual Studio 2013 Community Edition, the required SDKs, the MozillaBuild package, the Mercurial source repository and enough free disk space to compile. A fast SSD is recommended; the Firefox build process is I/O-intensive.
- A 64-bit version of Windows 7 (Service Pack 1) or later. While you can still build Firefox for 32-bit Windows and versions of Windows as old as XP/SP3, as of early 2015 Firefox will not compile successfully on most 32-bit Windows machines. Windows Vista and earlier do not support VS 2013 Community Edition.
The Mozilla build process requires many tools that are not installed on most Windows systems. In addition to Visual Studio, you must install MozillaBuild, which is a bundle of software including the right versions of bash, GNU make, autoconf, Mercurial, and much more.
The Mozilla codebase works with Visual Studio 2013 (VC12), which is used to compile out official releases. Please note that as of Firefox 37, earlier versions of Visual Studio will not work. We've started using features of C++11 that are not supported in Visual Studio 2012 and earlier.
Install build prerequisites
Complete each of these steps, otherwise you may not be able to build successfully. There are notes on these software requirements below.
- Make sure your system is up-to-date through Windows Update.
- Install Visual Studio Community 2013 (free). Alternatively, you can also use a paid version of Visual Studio (e.g. VS2013 Professional) or Visual Studio Express 2013 For Windows Desktop. The optional parts of the VS2013 Community install - including the Microsoft Foundation Classes for C++ - are not necessary to build Firefox. Earlier versions of Visual Studio are not supported; the Firefox codebase relies on C++ features that are not supported in VS2012 or earlier.
- Download and install the MozillaBuild package, containing additional build tools. If you have cygwin installed, read the note in the tips section. (After MozillaBuild's installer exits, if you see a Windows error dialog giving you the option to re-install with the 'correct settings', choose that option and after that all should be well.) More information about MozillaBuild and links to newer versions are available at https://wiki.mozilla.org/MozillaBuild.
- If you intend to build the Firefox Windows 8 UI (formerly known as Metro), see the additional information located at Windows 8 Integration - Building Locally.
In some circumstances, the following problems can arise:
MAPI header files required for building Thunderbird and SeaMonkey:
- You need to install the MAPI header files from http://www.microsoft.com/en-us/download/details.aspx?id=12905 because the MAPI header files are not bundled with Visual Studio 2013 (Windows SDK 8.1). You should copy the header files to a Windows SDK include directory so that the build process will find the files, for example to
C:\Program Files (x86)\Windows Kits\8.1\Include\shared.
To recreate a release build (all versions of Visual Studio):
- Install the June 2010 DirectX SDK. This is only needed so that the build can package an older version of the D3D compiler DLL (d3dcompiler_43.dll) from it, which is required for the builds to run on Windows XP.
There are several versions of Visual Studio Express 2013.
- " Windows Desktop" will work.
- The other options - "Visual Studio 2013 Express For Web" and "Visual Studio 2013 Express For Windows" - will not. Installing Visual Studio Community 2013 is recommended.
Please note that Mozilla will not build if some of the tools are installed at a path that contains spaces or other breaking characters such as pluses, quotation marks, or metacharacters. The Visual Studio tools and SDKs are an exception -- they may be installed in a directory which contains spaces. It is strongly recommended that you accept the default settings for all installation locations.
Opening a build command prompt
After the prerequisites are installed, launch one of the following batch files from the directory to which you installed MozillaBuild (
c:\mozilla-build by default):
for Visual Studio2013)
start-shell-msvcNNNN-x64.batfiles (unless you know what you're doing). Those files are experimental and unsupported. See the Build:MozillaBuild For x64 wiki page.
This will launch an MSYS / BASH command prompt properly configured to build one of the aforementioned code bases. All further commands should be executed in this command prompt window. (Note that this is not the same as what you get with the Windows CMD.EXE shell.)
Create a directory for the source
It's a sensible idea to create a new directory dedicated solely to the code:
cd /c; mkdir mozilla-source; cd mozilla-source
Now you are ready to get the Firefox source and build; continue on to Simple Firefox build (Get_the_source).
Command Prompt Tips and Caveats
- To paste into this window, you must right-click on the window's title bar, move your cursor to the Edit menu, and click Paste. You can also set Quick Edit Mode in the Properties menu and use a right-click in the window to paste your selection.
- If you have cygwin installed, make sure that the MozillaBuild directories come before any cygwin directories in the search path (use
echo $PATHto see your search path).
- In the MSYS / BASH shell, the c: drive looks like a directory called
cunder the root directory (/). So if you want to change to the directory
c:\mydir, in the MSYS shell you would use
cd /c/mydir. Note the UNIX-style forward slashes (/) in the prompt instead of the Windows-style backward slashes (\).
- The MSYS root directory is located in
c:\mozilla-build\msysif you used the default installation directory. It's a good idea not to build anything under this directory. Instead use something like
Common problems, hints, and restrictions
- Debugging Mozilla on Windows FAQ: Tips on how to debug Mozilla on Windows.
- The build may fail if your
PATHenvironment variable contains quotes ("). Quotes are not properly translated when passed down to MozillaBuild sub-shells. Quotes are usually not needed so they can be removed.
- The build may fail if you have a
PYTHONenvironment variable set. You will see an error almost immediately that says "
The system cannot find the file specified". In a command shell, typing "
SET PYTHON=" before running the Mozilla build tools in that same shell should fix this. Make sure that
PYTHONis actually unset, rather than set to an empty value. In the command shell, "
SET PYTHON" (without an equal sign or quotes) should respond: "
Environment variable PYTHON is not defined".
- The build may fail if you have cygwin installed. Make sure that the MozillaBuild directories (
c:\mozilla-buildand subdirectories) come before any cygwin directories in your PATH environment variable. If this does not help, remove the cygwin directories from PATH, or try building on a clean PC with no cygwin.
- Building with versions of NSIS other than the version that comes with the latest supported version of MozillaBuild is not supported and will likely fail.
- If you intend to distribute your build to others, you will need to set
WIN32_REDIST_DIR=$VCINSTALLDIR\redist\x86\Microsoft.VC80.CRTin your mozconfig to get the Microsoft CRT DLLs packaged along with the application.
- The Microsoft Antimalware service can interfere with compilation, often manifesting as an error related to
conftest.exeduring build. To remedy this, add at least your object directory to the exclusion settings.
- If you encounter an error that atlbase.h cannot be found and you have installed Visual Studio 10 Express together with the platform SDK, you may have to delete a registry entry so that guess-msvc.bat doesn't detect VC10 installed. The key is HKLM\SOFTWARE\Microsoft\VisualStudio\10.0\Setup\VC.
- If you encounter an error like "second C linkage of overloaded function '_interlockedbittestandset' not allowed", it happens when intrin.h and windows.h are included together. Use a #define to redefine one instance of the function's name. See more on using intrin.h.
- Parallel builds (
-jN) do not work with GNU make on Windows. You should use the
mozmakecommand included with current versions of MozillaBuild. Building with the
machcommand will always use the best available make command.
- If you still get random crashes when running
make, you may be encountering interference from Windows Security Updates that prevents proper operation of the Bash shell on some Windows systems. In this case, if you're on Windows XP, you will need to uninstall Windows XP Security Updates KB933729 and KB970238 using Add or Remove Programs from the Control Panel. The first of these Security Updates is also incorporated into Windows XP Service Pack 3 (KB936929), so if you have already installed SP3 you'll need to uninstall it and then make sure that Service Pack 2, including all Windows updates (EXCEPT KB933729, KB936929, and KB970238) get installed. To prevent these updates from being installed automatically, select "Notify me but don't automatically download or install them" in the Control Panel's "Automatic Updates" dialog. Then de-select them when any of these items appear in the list of recommended updates, and when asked, indicate that you don't want to be asked about these de-selected updates in the future.
Microsoft DirectX SDK (when using Windows SDK Version 7 or below)
If you are using a Windows SDK previous to version 8, the June 2010 DirectX SDK (specifically) is required for building the ANGLE GLES-on-D3D9 renderer for WebGL support on Windows. As part of the DirectX SDK install, you must install the End-User Redistributable Packages; don't uncheck it in the installer. For creating full release builds of Firefox, the June 2010 DirectX SDK is required with any Visual Studio version, but only so that an older version of the D3D compiler DLL (d3dcompiler_43.dll) can be packaged with the build for Windows XP compatability. For development on Windows 7 and later, the Windows 8 SDK contains all the necessary files to build.
Note: The DirectX SDK installer may display an "S1023" error during the final installation step. You may be able to simply ignore this error and continue with the Mozilla build process. If the Mozilla build system still cannot locate the DirectX SDK, see this Microsoft support page.
The MozillaBuild package contains the other software prerequisites necessary for building Mozilla. This includes the MSYS build environment, Mercurial, autoconf-2.13, CVS, Python, YASM, NSIS, and UPX, as well as optional but useful tools such as wget and emacs.
By default, the package installs to
c:\mozilla-build. It is recommended to use the default path. Don't use a path that contains spaces. The installer does not modify the Windows registry. Note that some binaries may require Visual C++ Redistributable package to run.
Expectation setting: Note that the "UNIX-like" environment provided by MozillaBuild is only really useful for building and committing to the Mozilla source. Most command line tools you would expect in a modern Linux distribution are not present, and those tools that are provided can be as much as a decade or so old (especially those provided by MSYS). It's the old tools in particular that can cause problems, since they often don't behave as expected, are buggy, or don't support command line arguments that have been taken for granted for years. For example, copying a source tree using
cp -rf src1 src2 does not work correctly because of an old version of cp (it gives "cp: will not create hard link" errors for some files). In short, MozillaBuild supports essential developer interactions with the Mozilla code, but beyond that don't be surprised if it trips you up in all sorts of exciting and unexpected ways.