You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.




Building Mozilla on Microsoft Windows 32-bit platforms using nmake

Daniel Nunes, leaf@mozilla.org


How to build Mozilla on a Microsoft Windows 32-bit System using nmake.

1. Introduction

2. Building Mozilla

3. Win32 Debugging FAQ

4. Common Problems


1. Introduction

What this document is: A guide to building the Mozilla application using nmake.
This includes:

  1. A listing of the development tools you will need to build Mozilla.
  2. A list of environment variables you will need to set before building.
Please note that building using nmake is unsupported when building using the Mozilla trunk. These instructions are provided as a convenience for existing branches that require nmake to build.

If you're looking for documentation on developing features or fixing bugs, the Mozilla Hacking Documents are probably what you're looking for.


2. Building Mozilla

    Each of the following subsections describes, or gives references to descriptions of, the steps necessary to build Mozilla.

    2.1 Requirements

    The following need to be installed for a standard win32 build:
    • Microsoft Visual C++ version 6.0 or later
      (make sure you have set up the compiler using the vcvars32.bat script that came with it. Version 5.0 will not work)
    • MSVC++ Service Pack 5
    • MSVC++ Processor Pack
    • GNU Tools for Microsoft Windows (the Cygnus toolkit): Specifically, you'll need the following packages:
        cygwin 1.1.6 or higher (b20.x is not good enough)
        ash
        diff
        fileutils
        gawk
        grep
        make
        sed
        sh-utils
        textutils
    • Netscape wintools:
        Netscape's wintools.zip contains pre-built libraries of libIDL & glib which are needed to build Mozilla, in addition to nsinstall, "our crackbaby install replacement." Unpack the zip file, and set MOZ_TOOLS to the directory you want the build tools installed to, for example:
          set MOZ_TOOLS=C:\moztools
        Do NOT set MOZ_TOOLS to point to your cygwin installation directory or a subdirectory of it. Do not set it to a directory name with spaces.
        Now, run the handy install script:
          cd buildtools\windows
          install.bat
        This batch script will install the files into %MOZ_TOOLS%/bin.
    • CVS for win32:
        Download WinCVS from http://www.cvshome.org . CVS version 1.10 or higher is required.
        The cygwin version of cvs will work IF you pull a fresh tree using cygwin cvs. See common errors for details.
    • Perl5 for win32:
    • Zip for win32:
    • Addition note for users inside Netscape firewall:
        Forget that \nstools ever existed. Remove it from your path.
        Building with a combination of nstools and cygwin is no longer supported.

    Hardware/OS

    • Pentium 133 MHz or better
    • 64 MB RAM, 128 MB recommended
    • 1 GB NTFS or 2 GB FAT disk space, or more
    • NT 4.0 is preferred
    • NT 3.51, Win95, Win98, and Windows 2000 will also work.

    2.2 Set Up The Build Environment

    For nmake builds, the following environment variables need to be set:
      set MOZ_BITS=32
      set MOZ_DEBUG=1
      (set this only if you want to build a debug build). to build optimized, undefine the variable by doing "set MOZ_DEBUG="
      set MOZ_NT=351
      (if running NT3.51) gmake.exe from the Windows Build Tools package resides there.)
      set MOZ_SRC=
      (top of your tree, for example: set MOZ_SRC=d:\mozilla_source if this is the directory where you checked out or unzipped the source into... don't end this line with a '\'... you'll be sorry if you do)
      set MOZ_TOOLS=
      (Set to the place where you want Netscape's wintools.zip to install its binaries. Do NOT overwrite your cygwin installation with wintools binaries . The build looks for MOZ_TOOLS\bin\gmake.exe, so make sure that the gmake.exe from the Windows Build Tools package resides there.)
      set OS_TARGET=WINNT
      (or WIN95)
      set WINOS=%OS_TARGET%
      set PATH=%PATH%;%MOZ_TOOLS%\bin;c:\cygwin\bin
      set _MSC_VER=1100
      (if you are running VC++ 5.0) or 1200 (if you are running VC++ 6.0) - or - set MOZ_VCVER=42 (for version 4.2, though no reports of successful compilation have been reported with 4.2)
      set DISABLE_TESTS=
      (Set this if you want to skip building in the test directories)
      set MOZ_DISABLE_JAR_PACKAGING=1
      (Set this if you want to disable jar packaging of the chrome)

    You also need to ensure that the PATH, INCLUDE, and LIB environment variables are set and that they include the paths to the Visual C++ files required to run the VC++ compiler from the command line.

    Visual C++ creates a file, VCVARS32.BAT, during the install that can set these for you. It can be found in D:\Program Files\Microsoft Visual Studio\VC98\Bin (this is the location in VC++6, the directory names differ in previous versions) and should be run prior to starting the build. Note that VCVARS32.BAT is created dynamically so, even if you have installed VC++ in a non-standard location, the paths it sets will be correct.

    2.3 Get The Code

    There are two principal ways of getting the code, ftp and CVS. CVS will provide the most current code for building, but is slower than ftp. Ftp drops are generally produced daily, and are known to compile.

    If you prefer to initially get the source via FTP then copy the tarball to your MOZ_SRC directory and uncompress it.

    2.4 Compile The Code

    Change to the directory that you set the variable MOZ_SRC to. (for example, cd d:\mozilla_source).

    If you already copied the source there from a tarball, there should be one directory here named mozilla. Change to that directory and run nmake with the build_all option so that nmake doesn't use CVS to update your tree.

    cd mozilla
    nmake /f client.mak build_all
    	

    If you're checking out the source via CVS, then check out the makefile, change to the new mozilla directory it creates, and run nmake. The makefile checks out the source and builds the tree in one step.

    
    cvs co  mozilla/client.mak
    cd mozilla
    nmake /f client.mak
    	

3. Win32 Debugging FAQ

Tips on how to debug Mozilla on Microsoft Windows platforms has been collected in the Win32 Debugging FAQ.


4. Common Sticking Points

  • nmake has a 'fatal error', listing one of the GNU commands and a hexadecimal return code.
      This will happen as a result of not having the GNU tools and Windows Build tools in your path. Add the directories with the appropriate binaries to your path.
  • Building on NT after upgrading from 98: nmake reports "Error U1045: spawn failed"
      COMSPEC environment variable needs to point to cmd.exe not command.com. When upgrading to NT this must be done manually.
  • It fails with the message "'.\WIN32' unexpected":
      You didn't properly set the environment variables -- you must not include a space at the end of the set statements (be careful if you are cut'n'pasting).
  • It fails to build, with directory-related errors:
      The full path to the source must not include any spaces. Additionally, the source must be extracted with an intact directory structure by a utility that understands long filenames. If in doubt, grab Info-Zip at ftp://ftp.cdrom.com/pub/infozip
  • It fails immediately with the message "Cannot find specified directory":
      You probably didn't properly set the environment variable MOZ_TOOLS; this needs to be set to the path up to, but not including, the final \bin directory in the path to the wintools. So, the path to the wintools executables is '%MOZ_TOOLS%\bin\'.
  • I'm not running a 32-bit windows system, how do i build?
      Currently, the build process depends on a 32-bit operating system. Windows NT 4.0 is the recommended windows operating system.
  • I'm not using the standard cmd.exe, and my build fails...
      Problems have been encounted using the 4nt command shell. 4nt interprets charactes like ';' in the makefile.win files as targets, and since there are no rules for the target ';', the build fails.
  • I checked in something that builds on Windows, but it breaks other platforms ...
  • The build breaks on Windows while creating jar files.
      Make sure you are using the 32 bit version of Zip for Windows 9x/NT (zip23xN.zip), and not the DOS/Win3.1 version (zip23x.zip). See bug 53005.
  • CVS fails with the message:
    cvs update: authorization failed: server XXXX rejected access
    cvs update: used empty password; try "cvs login" with a real password
    :
      Current versions of cygwin cvs (1.10.8) do not appear to be able to read files created by WinCVS. You will need to make sure that WinCVS is in your path before cygwin cvs. Alternatively, you can pull a fresh tree using cygwin cvs.
  • gmake errors with the message: Interrupt/Exception caught (code = 0xXXXXXXXXX, addr = 0...
      Newer versions of gmake are more strict about certain variable evaulation. In particular, make sure that SHELL is being evaluated immediately (ie, :=) when being set by a makefile. (Some versions of nsprpub/config/WIN32.mk had this problem.)
  • gmake errors with the message: SHMSDOS: cp: WIN954.0_OPT.OBJ\nspr4.dll: No such file or directory
      The way NSPR is built changed recently and you have leftover files from the old build in your source directory.
      To fix this, you can:
        Remove the nsprpub directory and repull it from CVS.
      or
        cd nsprpub
        sh configure
        gmake distclean
  • Make spits out an error about not being able to find a .dtd file
      You probably used WinZip to unpack the source archive. Don't do that. WinZip, by default, doesn't unpack 0 length files from tar.gz archives. Use another utility, or use the pull script to checkout the files that WinZip didn't extract.
  • 'nmake /f client.mak build_all' from a windows command shell gives the error:
    loading cache ./config.cache configure: error: can not run ./build/autoconf/config.sub
      This generally means that your cygwin directory/PATH environment has been modified somehow. This may happen if you have moved your cygwin installation on your hard drive to a path other than the location which it was originally installed. This can be worked around by the following - from the command shell (or in a .bat file) set the variable:
      set CONFIG_SHELL=C:/cygwin/bin/sh.exe (or wherever your sh.exe command exists - make sure to use forward slashes)
      This will force the build to use this specific sh.exe command, rather than its default of "/bin/sh" which generally doesn't exist from a windows command shell.