Building Firefox for Windows

Thank you for helping us build the world's best browser on the world's most popular OS. This document will will help you get set up to build and hack on your own version of Firefox on your local machine.

Getting set up won't be difficult, but it can take a while - we need to download a lot of bytes! Even on a fast connection, this can take ten to fifteen minutes of work, spread out over an hour or two.

The details are further down this page, but this quickstart guide should get you up and running:

Getting Ready.

To build Firefox on Windows, you need a 64-bit version of Windows 7 or later and about 40 GB of free space on your hard drive . You can make sure your version of Windows is 64-bit on Windows 7 by right-clicking Computer in your Start menu, clicking Properties and then System. On Windows 10, right-clicking the Windows menu button and choosing System will show you the same information.

Next, we want to start on a solid foundation: make sure you’re up to date with Windows Update and then we’ll get moving.

Getting The Tools.

Once you’re up to date, download and install Visual Studio Community 2015 from Microsoft. If you have an earlier version of Visual Studio, you'll need to upgrade; Firefox relies on C++ features that aren't supported in older versions of Visual Studio. There are optional extras that come with Visual Studio, but don't worry about them. They aren't required to build Firefox.  After Intallation, be sure to Launch Visual studio 2015 from the GUI to complete the first time run procedure to associate this insallation with an account.  Otherwise, you will be running an evaluation version which will not properly update via WIndows Update.

Next, download the MozillaBuild Package from Mozilla. Accept the default settings, in particular the default installation directory: c:\mozilla-build\. On some versions of Windows an error dialog will give you the option to "reinstall with the correct settings", and you should agree and proceed.

Once this is done, putting a shortcut to c:\mozilla-build\start-shell-msvc2015.bat on your desktop will make your life easier.

Getting Connected

That last step can take some time. While it’s finishing you should take a moment to sign up for a Bugzilla account!

Bugzilla.mozilla.org is Mozilla’s issue tracker. To comment on a bug or submit a patch you’ll need a Bugzilla account; you can use your GitHub account if you have one, or sign up for a Bugzilla account directly.

As well as Bugzilla, much of Mozilla’s internal communication happens over IRC. You can download Limechat here, and learn how to connect to Mozilla with IRC here. If you’re just getting started or have questions about getting set up you can join us in the #introduction channel, where some of our community members hang out to try and help new contributors get rolling.

Getting The Source

This is the last big step. Double-clicking the shortcut you’ve created will open a terminal window; start by creating a "mozilla-source" directory off of C:\ and cd into it like so

cd c:/

mkdir mozilla-source

cd mozilla-source

Next you can pull down the Firefox source code with Mercurial, our version control system, using this command:

hg clone https://hg.mozilla.org/mozilla-central

hg is the chemical symbol for mercury,

While you’re waiting for that process to finish, take a look at our Mercurial documentation. It explains how we use version control at Mozilla to manage our code and land changes to our source tree.

Build Firefox!

Now we tie it all together. In your terminal window, cd to your source directory as before and type

mach build

You’re on your way. Don’t be discouraged if this takes a while; this takes some time on even the fastest modern machines, and as much as two hours or more on older hardware. Firefox is pretty big, because the Web is big.

Join Mozillians.org!

There’s one more thing you can do for yourself while you’re waiting: create an account for yourself on Mozillians. Mozillians is the Mozilla community directory, where you can connect with people who share your interests, projects or countries. This step is optional, but we think it will be worth your while.

You're Ready.

When mach build completes, you'll have your own version of Firefox built from the source code on your hard drive, ready to run. You can run it with

mach run

... and now you have your own home-build version of Firefox.

If you saw an error here, look further down in this document for the "Troubleshooting" section - some antiviruses quarantine some of our tests, so you need to create execeptions for the "mozilla-source" and "mozilla-build" directories. Don't turn your antivirus off! Just add the exceptions.

Now the fun starts.

You have the code, you’ve compiled Firefox. Fire it up with ./mach run and you’re ready to start hacking. The next steps are up to you: join us on IRC in the#introduction channel, follow StartMozilla on Twitter and find a bug to start working on.

Thank you for joining us and helping us make Firefox and the open Web better for everyone.

Details and Troubleshooting

 

Hardware and software requirements

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 4 GB of RAM. 8 GB or more is recommended, and more is always better.
  • 35 GB free disk space. This amount of disk space accommodates Visual Studio 2015 Community Edition, the required SDKs, the MozillaBuild package, the Mercurial source repository and enough free disk space to compile. A solid-state hard disk is recommended; the Firefox build process is I/O-intensive.
  • A 64-bit version of Windows 7 (Service Pack 1) or later. As of early 2015, Firefox does not compile on most 32-bit Windows machines. You can still build Firefox for 32-bit Windows on versions of Windows as old as XP/SP3. Windows Vista and earlier do not support VS 2015 Community Edition.

Overview

The Mozilla build process requires many tools that are not preinstalled on most Windows  systems. In addition to Visual Studio, install MozillaBuild, a software bundle that includes the required versions of bash, GNU make, autoconf, Mercurial, and much more.

Firefox 48 and later build with Visual Studio 2015 in our official releases. You should be using Visual Studio 2015 to build all current versions of Firefox.

Firefox 37 through 47 build with Visual Studio 2013 (VC12) and possibly Visual Studio 2015 (although Visual Studio 2015 may not build every revision).

Earlier versions of Firefox build with older versions of Visual Studio.

Installing the build prerequisites

Complete each of these steps. Otherwise, you may not be able to build successfully. There are notes on these software requirements below.

  1. Make sure your system is up-to-date through Windows Update.
  2. Install Visual Studio Community 2015 (free). Be sure to install the "Common Tools for Visual C++ 2015", which requires a customized installation in Visual Studio 2015. Alternatively, you can also use a paid version of Visual Studio. The optional parts of the VS2015 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.
  3. Optionally, in addition to VS2015, you may want to also install Visual C++ 2008 Express (free) to compile some Python extensions used in the build system, because Python 2.7.x on Windows is built with that compiler by default. Note, if you want to use "mach resource-usage", "mach doctor", "mach android-emulator", or run talos tests locally, you should install it for building psutil.
  4. 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.

Troubleshooting

In some circumstances, the following problems can arise:

Some antivirus and system protection software can dramatically slow or break the build process:

  • Windows Defender and some scanning antivirus products are known to have a major impact on build times. As one example, if you have have cloned mozilla-central successfully but ./mach build fails reporting a missing file, you are likely experiencing this problem. Our regression tests for well-known security bugs can include code samples that some antivirus software will identify as a threat, and will either quarantine or otherwise corrupt the files involved. To resolve this you will need to whitelist your source and object directories (the mozilla-source and mozilla-build directories) in Windows Defender or your antivirus software and if you're missing files, revert your source tree with the "hg update -C" command. Once this is done your next ./mach build should complete successfully.

MAPI header files required for building Thunderbird and SeaMonkey:

  • You need to install the MAPI header files from Microsoft because the MAPI header files are not bundled with Visual Studio 2013/2015 (Windows SDK 8.1/10). 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 or C:\Program Files (x86)\Windows Kits\10\Include\10.0.nnnnn.0\shared respectively, where nnnnn is the highest number present on the system.

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.

Installing Visual Studio in a different language than the system can cause issues

  • For example, having Visual Studio in french when the system is in english causes the build to spew a lot of include errors and finishes by a link error.

Please note that Mozilla will not build if the path to the installation folder of some tools 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.

MozillaBuild

The MozillaBuild package contains other software prerequisites necessary for building Mozilla, including 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.

Download the current MozillaBuild package.

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.

MozillaBuild command prompt 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.

Opening a MozillaBuild command prompt

After the prerequisites are installed, launch one of the following batch files using the Windows command prompt in the directory to which you installed MozillaBuild (c:\mozilla-build by default):

  • start-shell-msvc2013.bat (Legacy. 32-bit build for Visual Studio 2013)
  • start-shell-msvc2013-x64.bat (Legacy. 64-bit build for Visual Studio 2013)
  • start-shell-msvc2015.bat (32-bit build for Visual Studio 2015 - for new contributors, this is the one you want.)
  • start-shell-msvc2015-x64.bat (64-bit build for Visual Studio 2015)

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

Note: You won't be able to build the Firefox source code if it's under a directory with spaces in the path (e.g., don't use "Documents and Settings"). You can pick any other location, such as a new directory c:/mozilla-source or c:/thunderbird-src. The build command prompt also tolerates "c:\" and  "/c/", but the former allows confusion with the windows command prompt, and the later is misinterpreted by some tools (at least MOZ_OBJDIR). The "C:/" syntax helps draw attention that the MozillaBuild command prompt is assumed from here on out since it provides configured environment and tools.

It's a sensible idea to create a new shallow directory, like "c:/mozilla-source" or "c:/thunderbird-src" dedicated solely to the code:

cd c:/; mkdir mozilla-source; cd mozilla-source

Keeping in mind the diagnostic hints below should you have issues, you are now you are ready to get the Firefox source and build; continue on to Simple Firefox build (Get_the_source), or another like Simple Thunderbird 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 right-click 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 enhanced by start-shell-msvc2015.bat (use echo $PATH to see your search path).
  • In the MSYS / BASH shell started by start-shell-msvc2015.bat, UNIX-style forward slashes (/) are used as path separators instead of the Windows-style backward slashes (\).  So if you want to change to the directory c:\mydir, in the MSYS shell to improve clarity, you would use cd /c/mydir though both c:\mydir and c:/mydir are supported.
  • The MSYS root directory is located in /c/mozilla-build/msys if you used the default installation directory. It's a good idea not to build anything under this directory. Instead use something like /c/mydir.

Common problems, hints, and restrictions

  • Debugging Mozilla on Windows FAQ: Tips on how to debug Mozilla on Windows.
  • The build may fail if your machine is configured with the wrong architecture. If you are using the 64-bit Mozilla build you may need this in your mozconfig file:
    ac_add_options --target=x86_64-pc-mingw32
    
    ac_add_options --host=x86_64-pc-mingw32
  • 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. It displays an error almost immediately that says "The system cannot find the file specified." In a command shell, typing "unset PYTHON" before running the Mozilla build tools in that same shell should fix this. Make sure that PYTHON is unset, rather than set to an empty value.
  • The build may fail if you have Cygwin installed. Make sure that the MozillaBuild directories (/c/mozilla-build and 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, set WIN32_REDIST_DIR=$VCINSTALLDIR\redist\x86\Microsoft.VC80.CRT in 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.exe during 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 does not 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 mozmake command included with current versions of MozillaBuild. Building with the mach command will always use the best available make command.

Warning: 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 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 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.

Return to the Build Documentation

Document Tags and Contributors

 Contributors to this page: WG9s, padenotmoz, mhoye, upsuper, mhoye_moz, Sebastianz, hashedhyphen, jonathanKingston, jorgk, nils, gps, JaredWein, mkato, overholt, rolfedh, vmunix, MattBrubeck, jdc2018, muqtada.husn, marco-c, cpeterson, csmwww, mauryat, rillian, WalterGR, aravindan1992, ksodari, SANJUBABA, Aryx, Ehsan, bgirard_github, poiru, vvuk, mshal, Ted_Mielczarek, Sheppy, emorley, q.dinar, Danw33, Nth10sd, kaustavM, kscarfone, ehoogeveen, Editmonkey, teoli, jswisher, estevamdf, ethertank, nnethercote, Luke314, Phoenix, Whimboo, markcapella@twcny.rr.com, BrianDiPalma, Oeekker, Albert_Iordache, SkyLined, Jonathan_Watt, NickolayBot, dbolter, BenB, SergeG, glandium, felipc, jenzed, jbuck, khuey, Steffen, jpshadow, Sid0, markg, Neil, bjacob, Yadra, Natch, VladVukicevic, Shaver, Imphil, toaarnio, sfink, DBaron, jlebar, fscholz, cgj, Jesse, kwright, Standard8, daveo, BenjaminSmedberg, goneri, Beltzner, Morac, CF, bezenek, rstrong, dzhulanov, Johnjbarton, Jorend, Cirne, Kinger, Hfcfboy, Zoun, Backinblakk, Mossop, Varun21, Dolske, Mook, Dmose, Plasticmillion, Callek, Jmathies, Lucas Malor, M32, FST777, Sbulut, Rasqual, Yuhong, Anonymoususr, Taken, George3, Biesi, Robin Monks, Abecevello, Ben Karel, Ivise301, Mgjbot, Glongword, NetRolller 3D, Benkarel, Dietrich, Nickolay, Robert Marshall, Mclark, Johnrw, RyanJones, Electrolysis, Fxysun, MykMelez, Elichak, Testperson, Ispiked, Kreeger, Napolj2, Themystic, Tuukka, Bzerodi, Sicking, Kozawa, Marria, Alfredkayser, Takenbot, Schapel, Qyb, DavidFraser, PikeUK, Mbwardle, Jak, Glazou, Wtchang, KaiRo, Ykrylov, JanWagner, Dria, BenoitL, O1k, ChrisCooper, Millie1, Metalspawn
 Last updated by: WG9s,