Building Firefox on Win32 using Visual Studio .NET 2005


The following is a description of the steps I took in order to successfully build Firefox trunk on Windows XP SP2 using Visual Studio.NET 2005 (known as VC8 on the Mozilla sites). I used all of the following resources at some point, but not one of them worked perfectly for me--your mileage may vary. At the time of writing, VS.NET 2005 is very new, and not much has been written on using it with Mozilla builds.

Please note that I am new to the build process, and am providing this in the same spirit as the caveman who brought fire back to the group after watching lightening strike a tree--I don't understand enough to tell you why some of this worked over other methods, so you should probably start by reading the official descriptions first, and know that this is here if they don't work:

  1. -- the official word on Win32 builds
  2. -- this is geared toward VC71 (VS.NET 2003)
  3. -- Vlad's blog entry about VC8 builds
  4. -- see especially the Visual Studio .NET 2005 section

Toward a custom Firefox: What Worked

  1. Install VS.NET 2005 using the default paths. For Seneca students/faculty, get it from and use your Learn/Mercury ID. If you want to build with free tools only, you should probably start with the links above, especially the last one.
  2. Install Cygwin following the instructions here with the following exception: don't use ActiveState Perl, use Cygwin Perl. I found that ActiveState Perl couldn't handle some of the scripts in the build system, but Cygwin/Perl did just fine. It may have been a version problem with ActiveState, I don't know; but Cygwin/Perl works fine, so don't complicate things.
  3. Make a directory for the source and build system
  4. mkdir C:\proj
  5. Download and Extract the static moztools libraries for Visual C++ to C:\proj\moztools
  6. Create a build script called C:\proj\buildsetup.bat to setup the appropriate environment variables and paths. You can copy and paste the following into this file:
  7. @echo off
    rem --- CVS Setup
    SET CVS_RSH=ssh
    rem --- Setup the paths to the moztools build libraries
    set MOZ_TOOLS=C:\proj\moztools
    rem --- Scrub these variables first
    SET LIB=
    SET PATH=C:\;C:\windows\system32;C:\windows\system32\wbem
    rem --- Prepend cygwin
    SET PATH=C:\cygwin\bin;%PATH%
    rem --- Setup VC8 compiler environment vars
    CALL "C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat" x86
    rem --- Add glib/libidl to build environment
    rem --- moztools comes last after glib/libIDL
  8. Move to C:\proj and setup your environment:
  9. [in c:\proj]
  10. Login to the mozilla CVS repository, using the password anonymous when prompted (NOTE: ignore the error message related to .cvspass):
  11. [in C:\proj]
    cvs login
  12. Checkout the build script
  13. [in C:\proj]
    cvs co mozilla/browser/config mozilla/
  14. This will have created a C:\proj\mozilla directory with a few files in it (the full source will get downloaded when you call make later).
  15. Create a text file named .mozconfig in C:\proj\mozilla. As I understand it, this file contains switches that need to get passed to configure--you don't run configure manually, so they go here. This is the .mozconfig file that worked for me, but you can read about it further here when you are ready to do more customized builds (i.e., after you get a simple build working):
  16. # Building Firefox Trunk with Debugging
    . $topsrcdir/browser/config/mozconfig
    # Put all obj files in one place, not in src tree
    mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/firefox-objdir
    ac_add_options --disable-static
    ac_add_options --enable-shared
    # Debug Build Setup Options
    ac_add_options --disable-optimize
    ac_add_options --enable-debug
    # I'm using Canvas for my work
    ac_add_options --enable-canvas
  17. Get the full source from CVS:
  18. cd \proj\mozilla
    make -f checkout
  19. Build the source:
  20. [in \proj\mozilla]
    make -f build
  21. Now wait (or in my case on my PIII laptop wait, wait, wait, wait, etc.). If it works, you'll have a newly built Firefox in C:\proj\mozilla\firefox-objdir\dist\bin. If it doesn't work, don't feel badly, as you can almost count on something going wrong.

How to get Help when things break

Google has some answers to various build problems, but I found that the next thing to try is IRC (irc://moznet/) and talk to the developers directly (they have been very helpful). I used both the #firefox and #developers channels, but probably the former is the best place to start. If you're new to IRC, as I was, grab ChatZilla and learn how to use it and pastebin, which allows you to paste snippets of code or other text on the web and then share the URL. The folks on IRC will ask you to paste your failed build messages there instead of flooding the IRC channel.