NOTE: Do not make substantive changes to this document without consulting Benjamin Smedberg <firstname.lastname@example.org> or one of the build-config peers.
This document is a guide to building Mozilla on Windows platforms. The Windows build uses a UNIX emulator for Windows, cygwin, to control the build process.
If you are building old versions of the Mozilla source code, from the 1.0 branch and earlier, read and follow the historical nmake build instructions.
Mozilla takes time to build. You need a development-class system:
- Pentium or equivalent processor, 266 MHz or better, 600MHz+ recommended
- 256 MB RAM, 512 MB recommended
- 1.5 GB NTFS or 3 GB FAT disk space, or more
- Windows NT-class operating system (NT4.0, Win2k, Windows XP Professional and XP Home Edition)
The following software needs to be installed for a standard Windows build.
Mozilla may not build if some tools are installed at a path that contains spaces or other breaking characters such as pluses, quotation marks, or meta characters. This does not apply to Visual C++ tools.
GNU Tools for Microsoft Windows (Cygwin)
cygwin is a UNIX-like environment for Windows. Mozilla uses a developer set of cygwin packages, which must be installed. These include gawk, make and zip utilities. GCC is not used and does not need to be installed. You must have cygwin 1.1.6 or higher. You can have only one cygwin version installed on your operating system; concurrent installations may interfere with each other and cause errors.
Go to http://www.cygwin.com/ and follow the installation instructions. The cygwin installer wizard runs as a Windows program. One page of the wizard presents an outline view of categories and packages. You must add packages beyond the default set.
If you'll be using cygwin only to build Mozilla, then install only the default packages and the packages needed by Mozilla. In the version of the installer current at this writing, the non-default packages are found under the categories Devel, Interpreters, and Archive: make (under Devel), perl and gawk (under Interpreters), and unzip and zip (under Archive).
If you may be using cygwin's UNIX-like tools for additional development, then install the editors, developer tools and interpreters, as well as anything else that looks interesting. Make sure you get all the packages Mozilla needs too, such as unzip and zip!
Here is the complete cygwin package list for building Mozilla. You can use it to double-check your packages, or to understand and customize the build process:
- ash -- UNIX-like command line interpreter shell (Base category)
- coreutils -- GNU core utilities (includes fileutils, sh-utils, and textutils) (Base category)
- diffutils -- file comparison utility (Base category)
- findutils (Base category)
- gawk -- pattern matching language (Base and Interpretors categories)
- grep -- text search tool (Base category)
- make -- dependency analyzer for software builds (Devel category)
- patchutils -- a small collection of programs that operate on patch files (Devel category)
- perl -- a scripting language used to control parts of the build (Interpreters category)
- sed -- a search and replace language (Base category)
- unzip -- zip file extraction (Archive category)
- zip -- zip file creation (Archive category)
If you plan to modify the build system's configure.in files, you will need to install the autoconf-2.13 (autoconf-stable) package as well.
It is hightly recommended to choose "DOS" style line endings from the cygwin installer.
You may use ActiveState perl instead of the perl package in cygwin if you prefer.
Netscape's wintools.zip contains pre-built libraries and tools which are needed to build Mozilla. When building with MSVC++ 7, you must install additional glib and libidl libraries, see below.
Unpack the zip file into a temporary directory, open a Windows command window, and set MOZ_TOOLS to the directory you want the build tools installed to, for example:
The MOZ_TOOLS directory should not be inside your cygwin installation directory, nor in a subdirectory of cygwin. This will cause your build to fail.
Run the wintools install script. This batch script will install the files into %MOZ_TOOLS%/bin.
cd buildtools\windows install.bat
CVS is the source control system used by Mozilla. You do not need cvs if you are only going to build from source tarballs downloaded via FTP. If so, you may skip this step.
To pull Mozilla sources, cvs version 1.11 or higher is required. Cygwin CVS is recommended. When installing CVS, you should also install an editor such as emacs.
Compiler & Linker
The standard compiler for Mozilla on Windows is Microsoft Visual C++, version 6. The GUI tools of the MSVC environment are not used, only the command-line tools CL (C/C++ compiler), LINK (linker), RC (resource compiler), and ML (assembler). Visual C++ Service Pack 5 and Visual C++ Processor Pack are required. Service Pack 6 is not supported. MSVC version 5 is not supported.
Make sure you have set up the compiler using the vcvars32.bat script that came with it. Run this file from the Windows command line shell.
It is possible to compile Mozilla using newer Microsoft visual C++ compilers such as edition 2002 (VC7.0), 2003 (VC7.1), or 2005 (VC8): see the new microsoft compiler build configuration.
It is also possible (but not recommended) to compile Mozilla using the mingw gcc compiler: see Compiling Mozilla With Mingw.
If you are using at least Visual Studio .NET 2003, you already have all the necessary SDKs for building mozilla and can skip this requirement step. For older compilers, you need to download SDKs from Microsoft to have the GDI+ headers and library.
The Platform SDK can be obtained from the Platform SDK Update site. You must install the "Windows Core SDK" (Tools, Build Environment, and Redistributable Components) and the "Web Workshop SDK" (Build Environment).
In order for the build environment to pick up this SDK, the following needs to be added to the environment (see below):
set PATH=C:\Program Files\Microsoft Platform SDK\bin;%PATH% set INCLUDE=C:\Program Files\Microsoft Platform SDK\include;%INCLUDE% set LIB=C:\Program Files\Microsoft Platform SDK\lib;%LIB%
Configure the Environment
Both the cygwin and MSVC++ tools are controlled by environment variables which specify options, directories, and search paths. cygwin inherits Windows environment variables and maps them into its own UNIX-style file system name space, so there are a variety of places you can set the variables. To build in cygwin, you can set both types in cygwin.bat at the root of the cygwin directory. To build from the Windows command shell, you may set these in a configuration file or in "My Computer -> Properties -> Advanced -> Environment Variables".
Your build may fail if your paths have spaces or other special characters. Make sure that you did not install software into locations with such paths, except Visual C++.
The following environment variables must be set:
- Set to the place where you want Netscape's wintools.zip to install its binaries. Mozilla will not build if you install the wintools directory inside the cygwin directory. The build looks for MOZ_TOOLS\include\glib.h, so make sure that the glib.h from the Windows Build Tools package resides there.
- Include both the Netscape wintools and the cygwin UNIX-like tools in your command search path.
Note: to avoid problems with a cygwin utility called "link", the MSVC binaries should be in the PATH before cygwin/bin. This can be accomplished by calling <tt>vcvars32.bat</tt> after setting PATH as shown above.
Note: for .NET/VC7 users: %GLIB_PREFIX%/bin and %LIBIDL_PREFIX%/bin must be in your path before %MOZ_TOOLS%/bin.
In general, the order of directories in PATH should be as follows:
See the examples below for a way to get it set up like that.
- HOME is not needed if you are not using cvs. If you are, set it to the place where you want cvs to create your .cvspass file. By setting HOME, you tell cvs to use the same .cvspass file whether you use the Windows shell or a cygwin shell. Because cygwin cvs or other cygwin programs may use this variable, it should not contain breaking characters.
Note: if you are using ssh, your HOME should match the home directory specified in /etc/passwd. See the cygwin FAQ.
If you decide to set up your environment using a configuration file as mentioned above, you may create a new batch file or edit cygwin.bat and, as a reference, start with one of the following files.
- Here's an example for VC7:
@echo off rem --- Basic config, with VC7 libIDL files SET MOZ_TOOLS=C:\moztools SET GLIB_PREFIX=C:\moztools\vc7_files SET LIBIDL_PREFIX=C:\moztools\vc7_files SET MINGWBASE=C:\Dev-Cpp SET CYGWINBASE=C:\cygwin rem --- Clean slate start SET INCLUDE= SET LIB= SET PATH=C:\;C:\windows\system32;C:\windows;C:\windows\system32\wbem rem --- Then prepend Cygwin path SET PATH=%CYGWINBASE%\bin;%PATH% rem --- Set VC7 compiler environment vars CALL D:\vStudio.NET2003\Vc7\bin\vcvars32.bat rem --- Add glib/libidl to build environment SET PATH=%PATH%;%GLIB_PREFIX%;%GLIB_PREFIX%\bin SET INCLUDE=%GLIB_PREFIX%\include;%INCLUDE%;%MINGWBASE%\include SET LIB=%GLIB_PREFIX%\lib;%LIB% rem -- moztools comes last after glib/libIDL SET PATH=%PATH%;%MOZ_TOOLS%\bin\
- Here's an example for VC6 which also shows how to set up your paths so you can make the installer:
@echo off rem --- Basic config SET MOZ_TOOLS=C:\moztools SET CYGWINBASE=C:\cygwin SET HOME=%CYGWINBASE%\home\YOUR_USERNAME_HERE rem --- Clean slate start SET INCLUDE= SET LIB= rem PATH needs to be constructed carefully to avoid conflicts rem between the binaries that Windows and Visual Studio provide rem and those that Cygwin provides. In particular, MSVC's "link" rem utility should override Cygwin's, and Cygwin's "find" utility rem should override Windows'. rem First set up basic Windows paths. SET PATH=C:\;C:\windows\system32;C:\windows;C:\windows\system32\wbem rem Then prepend Cygwin path and append Moztools path. SET PATH=%CYGWINBASE%\bin;%PATH%;%MOZ_TOOLS%\bin rem Finally, prepend MSVC paths using vcvars32.bat. call C:\msvs\VC98\bin\vcvars32.bat rem Now the PATH variable contains: rem MSVC paths + Cygwin path + Windows paths + Moztools path C: chdir C:\cygwin\home\YOUR_USERNAME_HERE bash --login -i
Common Problems and Hints
- Check the Mozilla Build Frequently Asked Questions
- Your source tree must be located at a /cygdrive/<c> mount point. It must not be located within your /home.
- Mozilla may not build if you install the wintools directory inside the cygwin directory.
- If the configure or build fails due to a missing w32api, add the mingw32's /include directory to the end of your INCLUDE environment variable. Mingw32 libraries or binaries should not be needed, only the headers.
- The build may fail if your PATH environment variable contains quotes ("). Quotes are not properly translated when passed down to the cygwin sub-shells. Quotes are usually not needed so they can be removed.
- Double-check to make sure that you have the complete cygwin package list. If not, launch the cygwin installer and add the missing packages.
- Win32 Debugging FAQ: Tips on how to debug Mozilla on Windows.
- Upgrading a Windows build system from VC6 to VC7?