Compiling Mozilla With Mingw
From MDC
This article explains how to use Mingw to build Mozilla projects on Windows without using Microsoft Visual Studio, in 14 steps. The versions built using these instructions are debug builds.
[edit] Disk space requirements
You will need at least 3.7 GB of free disk space in order to download the source code and install the needed build tools, as well as to build the software.
[edit] Create the main directory
All the tools and code will be located in C:\mozilla\, so create this directory first. From a command prompt, issue the command:
mkdir C:\mozilla\
[edit] Get the GNU tools for Microsoft Windows (Cygwin)
Download the Cygwin tools for Windows. This is a special version of the GNU tools that runs on Windows:
Install the tools into C:\mozilla\cygwin\. Remember to choose Unix as the Default Text File Type.
In addition to the default modules, you need to install:
- cvs (Devel)
- cygutils (Utils)
- make (Devel)
- patch (Utils)
- patchutils (Devel)
- perl (Perl)
- unzip (Archive)
- zip (Archive)
To select these optional installs, press the View button in the Select Packages part of the installer.
The following needed modules should be part of the default install, but you may wish to confirm that they're selected:
- ash
- diffutils
- fileutils
- findutils
- gawk
- grep
- sed
- sh-utils
- textutils
[edit] Get the Mozilla 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.
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
[edit] Get MinGW
Download the following set of 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 starting a Command Prompt and doing the following:
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
[edit] Create the settings file
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
[edit] Run the settings file
Get ready to get the Mozilla source code. Issue the following commands at the command prompt:
cd c:\mozilla\ mozset.bat
Keep the command prompt open after doing this.
[edit] Convert the headers into Unix format
Since we're on a Windows platform we have to convert the Mozilla wintools header files into Unix format.
cd c:\mozilla\moztools\include\ dos2unix.exe *.h cd libIDL\ dos2unix.exe *.h
[edit] Now login to the CVS server
Log into the Mozilla CVS server:
cd c:\mozilla\ cvs login
Enter "anonymous" as the password when asked. 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.
[edit] 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
[edit] Create the .mozconfig file
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
[edit] Get the source
Now you are ready to pull the source. This will take a long time!
cd c:\mozilla\mozilla\ make -f client.mk pull_all
It's much faster to download the source directly. You can get the source by downloading a tarball containing all the source files:
[edit] Build
Now build the bird! This will take a even longer than fetching the code; exactly how long depends on your system.
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
[edit] Start it up
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
[edit] Troubleshooting
Here are some helpful troubleshooting tips.
[edit] Make sure your tools are correct
First of all make sure that you're using the correct tools.
[edit] 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.
[edit] Test make
cd c:\mozilla\ mozset.bat make -v
This should say GNU Make 3.80. If it doesn't something is wrong.
[edit] 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.
[edit] 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
This error means that it can't find the file cl. The cl file is the Microsoft Visual C++ compiler. You want to be using 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.
[edit] Problems with cdefs.h
If you're getting the error:
sys/cdefs.h: No such file or directory
Solution: Make sure that the mingw path is before the cygwin path.
[edit] Problems with glib.h
Solution: [[#Convert the headers into Unix format|Convert] the moztools header files with dos2unix.
[edit] Parse error
You see errors like this:
parse error before '*' token
Solution: [[#Convert the headers into Unix format|Convert] the moztools header files with dos2unix.
[edit] Missing midl
If you get this error:
"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.
[edit] 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 the following to your .mozconfig:
LDFLAGS="-mwindows -Wl,--enable-runtime-pseudo-reloc"
[edit] Problems with missing icons
If you're having problem with the icons not being shown in 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 must 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 your icons will be corrupted.
Solution: Copy the chrome directory over from a "real" Mozilla Thunderbird build.
[edit] No build ID
If you build Mozilla and it doesn't have a build ID, you should add the following to your mozset.bat file set:
MOZILLA_OFFICIAL=1 set BUILD_OFFICIAL=1
[edit] See also
[edit] Original Document Information
- Author(s): Henrik Gemal
- Last Updated Date: February 6, 2008
- Copyright Information: 1995-2006 Henrik Gemal

