Build Mozilla Thunderbird/Firefox/Sunbird on Microsoft Windows

I'm a Mozilla fan! And being able to build Mozilla Thunderbird and/or Mozilla Firefox on my Windows XP machine sounded cool.

I didn't have Microsoft Visual C++ so I needed to build without any tools from Microsoft, aside from Windows XP of couse.

So here we go: Build Mozilla Thunderbird and/or Mozilla Firefox and/or Mozilla Sunbird in 14 easy steps!

The versions that you're building will be debug versions. This means that a console will appear with some debug messages. They will also run slower than the versions that you can obtain from mozilla.org.

1. Disk space requirements

Be sure you have enough disk space available. You must have 3.7GB free disk space available. The building tools are around 110MB. The Mozilla source before building it is around 200Mb.

2. Create main directory

All tools and code will be located in c:\mozilla\. Therefore start by creating this directory. Start a Command Prompt and do:
mkdir c:\mozilla\

3. Get GNU Tools for Microsoft Windows (Cygwin)

Install the GNU Tools for Microsoft Windows (also called Cygwin) : Direct download - Info

Install into : c:\mozilla\cygwin\. Remeber to choose Unix as "Default Text File Type". Besides the default modules, install the following modules:

  • cvs
  • cygutils
  • make
  • patch
  • patchutils
  • perl
  • unzip
  • zip

You do this by pressing the View button in the Select Packages part of the installer. Click here to see the screenshots.

Cygwin installation
<- Prev Image    Image 1 of 9    Next Image ->

The following modules should be installed per default. But make sure that they are selected:

  • ash
  • diffutils
  • fileutils
  • findutils
  • gawk
  • grep
  • sed
  • sh-utils
  • textutils

4. Get Netscape wintools

Netscape has modified a handful of the GNU command-line tools to solve some problems mostly for makefile compatibility with the GNU-styled UNIX builds.

Get Netscape wintools : Direct download

Unpack the zip file into a temporary directory. Then start a Command Prompt in the temporary directory and do:

set MOZ_TOOLS=c:\mozilla\moztools
mkdir c:\mozilla\moztools
cd buildtools\windows
install.bat

5. Get MinGW

Get the following MinGW packages:

Unpack all of the tar.gz files in c:\mozilla\mingw\. You can do this by placing all the tar.gz files in c:\mozilla\mingw\ and then Start a Command Prompt and do:

cd c:\mozilla\mingw\
c:\mozilla\cygwin\bin\gzip -d *.tar.gz
c:\mozilla\cygwin\bin\tar -xvf binutils-*
c:\mozilla\cygwin\bin\tar -xvf gcc-core-*
c:\mozilla\cygwin\bin\tar -xvf gcc-g++-*
c:\mozilla\cygwin\bin\tar -xvf mingw-runtime-*
c:\mozilla\cygwin\bin\tar -xvf w32api-*
del *.tar

6. Set up

Create a file called mozset.bat in c:\mozilla\. The file should contain the following lines:
@echo off
set MOZ_TOOLS=c:\mozilla\moztools
set PATH=c:\mozilla\mingw\bin;c:\mozilla\cygwin\bin;%MOZ_TOOLS%\bin;%PATH%
set HOME=c:\mozilla
set CVSROOT=:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot

7. Run mozset.bat

Get ready for to get the Mozilla source code. Do:
cd c:\mozilla\
mozset.bat

Keep the Command Prompt open.

8. Header convert

Since we're on a Windows platform we have to convert the Netscape wintools header files into Unix format.
cd c:\mozilla\moztools\include\
dos2unix.exe *.h
cd libIDL\
dos2unix.exe *.h

9. Now login to the CVS server

Log into the Mozilla CVS server.
cd c:\mozilla\
cvs login

Enter anonymous as password. You might get a warning like:

cvs login: warning: failed to open /cygdrive/c/mozilla/.cvspass for reading: No such file or directory

Just ignore it.

10. Get client.mk

Get the client.mk file which does all the magic:
cd c:\mozilla\
cvs checkout mozilla/client.mk

If you want to build Mozilla Firefox do

cd c:\mozilla\
cvs checkout mozilla/browser/config

If you want to build Mozilla Thunderbird do

cd c:\mozilla\
cvs checkout mozilla/mail/config

If you want to build Mozilla Sunbird do

cd c:\mozilla\
cvs checkout mozilla/calendar/sunbird/config

11. Create .mozconfig

Now you have to create a file called .mozconfig in c:\mozilla\mozilla\
It should contain the following lines:

To build Mozilla Thunderbird in optimized mode:

. $topsrcdir/mail/config/mozconfig
CC=gcc
CXX=g++
CPP=cpp
AS=as
LD=ld
ac_add_options --disable-accessibility

To build Mozilla Thunderbird in debug mode, that's with the debug information and console window:

. $topsrcdir/mail/config/mozconfig
CC=gcc
CXX=g++
CPP=cpp
AS=as
LD=ld
ac_add_options --disable-accessibility
ac_add_options --enable-debug
ac_add_options --disable-optimize

To build Mozilla Firefox in optimized mode:

. $topsrcdir/browser/config/mozconfig
CC=gcc
CXX=g++
CPP=cpp
AS=as
LD=ld
ac_add_options --disable-accessibility

To build Mozilla Firefox in debug mode, that's with the debug information and console window:

. $topsrcdir/browser/config/mozconfig
CC=gcc
CXX=g++
CPP=cpp
AS=as
LD=ld
ac_add_options --disable-accessibility
ac_add_options --enable-debug
ac_add_options --disable-optimize

To build Mozilla Sunbird in optimized mode:

. $topsrcdir/calendar/sunbird/config/mozconfig
CC=gcc
CXX=g++
CPP=cpp
AS=as
LD=ld
ac_add_options --disable-accessibility

To build Mozilla Sunbird in debug mode, that's with the debug information and console window:

. $topsrcdir/calendar/sunbird/config/mozconfig
CC=gcc
CXX=g++
CPP=cpp
AS=as
LD=ld
ac_add_options --disable-accessibility
ac_add_options --enable-debug
ac_add_options --disable-optimize

12. Get the source

Now you are ready to pull the source. This will take a long time! It took me around 2 hours!
cd c:\mozilla\mozilla\
make -f client.mk pull_all

It's much faster to download the source directly. You could get the source by downloading a tar.gz file containing all the source files : Direct download - Info

13. Build

Now build the bird! This will take a even longer time! It took me around 4 hours!
cd c:\mozilla\mozilla\
make -f client.mk build_all
If you want to log all warnings and errors to a file you can do it by doing:
cd c:\mozilla\mozilla\
make -f client.mk build_all > c:\mozilla\build.log 2>&1
The next time if want to update and build you can do this by doing:
cd c:\mozilla\mozilla\
make -f client.mk pull_and_build_all

14. Start it

To start Mozilla Thunderbird:

cd c:\mozilla\mozilla\thunderbird\bin\
thunderbird.exe -console

To start Mozilla Firefox:

cd c:\mozilla\mozilla\dist\bin\
firefox.exe -console

Moving on...

Now that you have build Mozilla Thunderbird you can now start to modify code. Fx if you want to change some IMAP code, go to c:\mozilla\mozilla\mailnews\imap\src\ change the code and do:
cd c:\mozilla\mozilla\mailnews\imap\
make
cd build
make

You can now launch thunderbird.exe again and your code changes should be there.

If you want to get the updated Mozilla source files into your directory and build it do:

cd c:\mozilla\
mozset.bat
cd mozilla
make -f client.mk

Problems

Make sure that your tools are correct

First of all make sure that you're using the correct tools.

Test gcc

cd c:\mozilla\
mozset.bat
gcc -v
This should say gcc version 3.2.3 (mingw special 20030504-1). If it doesn't something is wrong.

Test make

cd c:\mozilla\
mozset.bat
make -v
This should say GNU Make 3.80. If it doesn't something is wrong.

Test uname

cd c:\mozilla\
mozset.bat
uname --version
This should say uname (sh-utils) 2.0.15. If it doesn't something is wrong. Double check that the path to your Cygwin binary directory is set up correctly in mozset.bat.

Other problems

I encountered the following problems while trying to compile Mozilla Thunderbird:

exec: cl: not found

make[4]: Entering directory `/cygdrive/c/mozilla/mozilla/nsprpub/config' sh /cygdrive/c/mozilla/mozilla/nsprpub/build/cygwin-wrapper cl -Fonow.obj -c -W3 -nologo -GF -Gy -MDd -Od -Z7 -UNDEBUG -DDEBUG_hege -UWINNT -DMOZILLA_CLIENT=1 -DDEBUG=1 -DXP_PC=1 -DWIN32=1 -D_DEBUG=1 -DWIN95=1 -D_PR_GLOBAL_THREADS_ONLY=1 -D_X86_=1 -DFORCE_PR_LOG /cygdrive/c/mozilla/mozilla/nsprpub/config/now.c
exec: cl: not found

Basically it complains that it can't find the file cl. The cl file is the Microsoft Visual C++ compiler. You use the gcc compiler instead of the MinGW compiler.

Solution: Double check that the path to your Cygwin binary directory is set up correctly in mozset.bat. Also make sure that the mingw path is before the MOZ_TOOLS path.

Problems with cdefs.h

If you're getting: sys/cdefs.h: No such file or directory

Solution: Make sure that the mingw path is before the cygwin path.

Problems with glib.h

Solution: Convert the moztools headers files with dos2unix.

Parse error

You see errors like this parse error before '*' token

Solution: Convert the moztools headers files with dos2unix.

Missing midl

If you get "midl" c:/mozilla/mozilla/accessible/public/msaa/ISimpleDOMNode.idl
"midl" not found

Solution: The following options don't yet work under gcc-on-win32 so you have to disable them

ac_add_options --disable-accessibility
ac_add_options --disable-activex

Currently the mingw headers and libraries don't emulate accessibility. Perhaps at a some point mingw will.

Problems with "vtable cant be auto-imported"

Some people have been having "vtable" problems when compiling. It says something like "variable vtable cant be auto-imported".

Solution: To fix this problem try adding following to your .mozconfig

LDFLAGS="-mwindows -Wl,--enable-runtime-pseudo-reloc"

Problems with missing icons

If you're having problem with the icons not being shown in the Mozilla Thunderbird, it's because you didn't choose Unix as the default file type when installing cygwin.
cd c:\mozilla\
mozset.bat
mount
Then it most say:
C:\mozilla\cygwin\bin on /usr/bin type system (binmode)
C:\mozilla\cygwin\lib on /usr/lib type system (binmode)
C:\mozilla\cygwin on / type system (binmode)
c: on /cygdrive/c type user (binmode,noumount)

The important thing is that it says binmode and not textmode. Otherwise you're icons are trashed!

Solution: Copy the chrome directory over from a "real" Mozilla Thunderbird build.

No build ID

If you build Mozilla and dont get an build ID you should add the following to your mozset.bar file set MOZILLA_OFFICIAL=1
set BUILD_OFFICIAL=1

More resources...

Relevant bugs...

.
You're here: Home - Mozilla - Build Mozilla Thunderbird/Firefox/Sunbird on Microsoft Windows
Get the Mozilla Firefox browser