This page covers the steps needed to prepare your machine to build a bleeding-edge, development version of Firefox on Windows.
Mozilla takes time to build. You need a development-class system:
- A fast processor, ideally with several cores.
- More than 2 GB of RAM for recent Firefox builds, 4 GB or higher recommended.
- 1.5 GB NTFS or 3 GB FAT disk space, or more
- Windows Vista or later recommended (the build should work on Windows XP though).
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 just the right versions of bash, GNU make, autoconf, Mercurial, and much more.
The Mozilla codebase works with the following compilers ("Official" means this is what we use for the builds we release as the Firefox product):
|VC8 (Visual Studio 2005)||VC9 (Visual Studio 2008)||VC10 (Visual Studio 2010)||VC11 (Visual Studio 2012)|
Note that installing both Visual Studio 2010 and Visual Studio 2012 on Windows 64-bit currently breaks the build. Also installing .NET Framework 4.5 when using Visual Studio 2010 breaks the builds. See Bug 772989 Comments 15 and 17 on this, according to http://support.microsoft.com/kb/2757355 installing Visual Studio 2010 SP1 should fix this problem.
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. (Windows XP needs at least Service Pack 2 and .NET Framework 2.0.)
- You may need to install one or more Windows SDKs. See Windows SDK versions for a quick guide.
- Install the June 2010 DirectX SDK (even VS 2012 requires this).
- Install a version of Visual Studio that supports C++ development: VS 2012 for Windows Desktop Pro or Express (free), or VC++ 2010 Pro or Express (free).
- Install MozillaBuild, a package of additional build tools. (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.) If you have cygwin installed read the note is the tips section.
- Add the folders with relevant .dlls to your PATH (in advanced system settings). When you get errors about missing .dll files, you will need to find the folder containing the dll and add it to the PATH environment variable.
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 meta characters. But the Visual C++ tools are an exception -- they may be installed in a directory which contains spaces, and the default install location is preferred.
Opening a Build Command Prompt
After the prerequisites are installed, launch one of the following batch files from the
start-msvc10.bat (VS 2010)
start-msvc11.bat (VS 2012)
start-msvcX-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 a 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).
This must be launched with administrator privileges. If you have User Account Control (UAC) turned on, it may not be granted automatically. Right click the .BAT file and select "Run as Administrator".
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/mydirNote 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.
- Note that in Windows you need to build with Administrator privileges. If you have User Account Control (UAC) turned on, it may not automatically grant that to you.
- The build may fail if your PATH environment 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 PYTHON environment variable set. You will see an error almost immediately that says "
The system cannot find the file specified". In a cmd-shell typing "SET PYTHON=" before running mozilla build tools in that same shell should fix this.
- 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.
警告: If you follow the below advice, your computer will not be protected against attacks that exploit this vulnerability. Make sure you take adequate precautions.
- If you still get random crashes when running MAKE, you may be encountering interference from Windows Security Updates that prevent 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.
- Parallel builds (-jN) do not work with GNU make on Windows. You need to use pymake instead.
Microsoft DirectX SDK
The June 2010 DirectX SDK (specifically) is required for building the ANGLE GLES-on-D3D9 renderer, which is required on Windows for WebGL rendering. (If you don't care about compatibility with official Firefox builds and want to avoid installing this large SDK, you can disable WebGL by building Mozilla with the --disable-webgl option.) As part of the DirectX SDK install, you must install the End-User Redistributable Packages; don't uncheck it in the installer. (At least prior to Win7+VS2012?)
(Note that other versions of the DirectX SDK on Microsoft's Developer Center that claim to have been released after June 2010 are actually older versions that are misdated, some of which will result in an error if you try and download them due to the installer files themselves having been removed from the MS servers. There will not be any further standalone DirectX SDKs released by MS, since DirectX has been transitioned from an independent distribution model to an integrated (into Windows and Visual Studio) model, and the DirectX SDK is now integrated into the Windows 8 SDK (which is bundled with Visual Studio as of VS2012) [ref]. The reason that we require the June SDK even on newer Win7+VS2012 systems is because ANGLE depends on D3DX9, but MS considers D3DX to have been obsoleted by newer technologies and therefore VS2012 don't include the d3dx9.h and d3dx9tex.h headers that are required to compile ANGLE. Any queries about this paragraph, talk to Jonathan Watt.)
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.
The MozillaBuild package includes the "make" program that originated on the UNIX and Linux platforms. This version of make does not make use of Windows' multi-core architecture. pymake is a Python implementation of Make that uses Window's multi-core architecture and thus significantly speeds up build time.