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 inc:\mozilla\
. Therefore start by creating this directory. Start a Command Prompt and do:
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.
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:
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:
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 calledmozset.bat
in c:\mozilla\
. The file should contain the following lines:
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: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.dos2unix.exe *.h
cd libIDL\
dos2unix.exe *.h
9. Now login to the CVS server
Log into the Mozilla CVS server.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 theclient.mk
file which does all the magic:
cvs checkout mozilla/client.mk
If you want to build Mozilla Firefox do
cvs checkout mozilla/browser/config
If you want to build Mozilla Thunderbird do
cvs checkout mozilla/mail/config
If you want to build Mozilla Sunbird do
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:
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:
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:
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:
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:
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:
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!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!make -f client.mk build_all
make -f client.mk build_all > c:\mozilla\build.log 2>&1
make -f client.mk pull_and_build_all
14. Start it
To start Mozilla Thunderbird:
thunderbird.exe -console
To start Mozilla Firefox:
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 toc:\mozilla\mozilla\mailnews\imap\src\
change the code and do:
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:
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
mozset.bat
gcc -v
gcc version 3.2.3 (mingw special 20030504-1)
. If it doesn't something is wrong.
Test make
mozset.bat
make -v
GNU Make 3.80
. If it doesn't something is wrong.
Test uname
mozset.bat
uname --version
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 thisparse 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.mozset.bat
mount
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 fileset MOZILLA_OFFICIAL=1
set BUILD_OFFICIAL=1
More resources...
- Building Mozilla Thunderbird Mail
- Mozilla Thunderbird
- How to build Mozilla on a Microsoft Windows System
- Getting Mozilla source code via cvs
- Mozilla Build FAQ
- How to get Mozilla source code
- Mozilla Thunderbird Build forum
- Building A Mozilla Distribution