Hardware ups and downs, part 3: Setting up your build on Windows Vista 64-bit

Success! After my previous attempts, I have finally figured out how to build Mozilla Firefox 3.0 on my Windows Vista 64-bit operating system. It involves doing a couple things you may not have thought of.

As for the RAM disk part, I haven’t attempted that yet. Read on in the extended entry for details.

Required software

http://developer.mozilla.org/en/docs/Windows_Build_Prerequisites lists them, but here’s my short list:

  • Visual C++ 2005 Express Edition (VC8)
  • Microsoft Windows Vista SDK (for wpcapi.h)
  • Microsoft Windows Server 2003 R2 Platform SDK (for atlbase.h)
  • MozillaBuild 1.3
  • MSYS 1.0.11 new DLL’s and executables

Don’t install them yet!! You have to make some modifications to the above items.

MSYS in MozillaBuild 1.3 doesn’t work with 64-bit Windows

cstrauss offers a fix in the MSYS 1.0.11 tarball I mentioned above. First, you need to install MozillaBuild. Then you unpack the contents of the tarball into C:\mozilla-build\msys\bin\. Since MozillaBuild doesn’t work until you do this, you can’t just use MozillaBuild’s command line. I recommend 7-Zip.

Spaces in file names… they’re baaaaaaaaaaaaaaaaaaaaaaaack…

The batch files for guess-msvc.bat don’t react well to spaces in file names. MozillaBuild 1.3 can’t recover. I found that I could easily specify the install location for VC8, but the others I never figured out. So they ended up with long and spacey directory names like C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2 and C:\Program Files\Microsoft SDKs\Windows\v6.1\. (VC8 I put in C:\VC8Express\.)

The solution? An old MS-DOS trick. Save this as a new batch file (I called mine start-ajv-msvc8.bat).

subst s: "c:\Program Files\Microsoft SDKs\Windows\v6.1"
set SDKDIR=s:\
set SDKVER=6
set SDKMINORVER=1
subst t: "C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2"
set PSDKDIR=t:\
set PSDKVER=5
call c:\mozilla-build\start-msvc8.bat

You’ll need to replace c:\mozilla-build\guess-msvc.bat (I just commented out a few lines) with this:

REM -*- Mode: fundamental; tab-width: 8; indent-tabs-mode: 1 -*-
@ECHO OFF
set CYGWIN=
if not defined MOZ_NO_RESET_PATH (
set PATH=%SystemRoot%\System32;%SystemRoot%;%SystemRoot%\System32\Wbem
)
REM if DISPLAY is set, rxvt attempts to load libX11.dll and fails to start
REM (see mozilla bug 376828)
SET DISPLAY=
SET INCLUDE=
SET LIB=
SET MSVCROOTKEY=HKLM\SOFTWARE\Microsoft\VisualStudio
SET MSVC6KEY=%MSVCROOTKEY%\6.0\Setup\Microsoft Visual C++
SET MSVC71KEY=%MSVCROOTKEY%\7.1\Setup\VC
SET MSVC8KEY=%MSVCROOTKEY%\8.0\Setup\VC
SET MSVC8EXPRESSKEY=HKLM\SOFTWARE\Microsoft\VCExpress\8.0\Setup\VC
SET MSVC9KEY=%MSVCROOTKEY%\9.0\Setup\VC
SET MSVC9EXPRESSKEY=HKLM\SOFTWARE\Microsoft\VCExpress\9.0\Setup\VC
REM First see if we can find MSVC, then set the variable
REM NOTE: delims=
REM NOTE: run the initial REQ QUERY outside of the if() to set ERRORLEVEL correctly
REG QUERY "%MSVC6KEY%" /v ProductDir >nul 2>nul
if "%VC6DIR%"=="" (
IF %ERRORLEVEL% EQU 0 (
FOR /F "tokens=2* delims=	 " %%A IN ('REG QUERY "%MSVC6KEY%" /v ProductDir') DO SET VC6DIR=%%B
)
)
REG QUERY "%MSVC71KEY%" /v ProductDir >nul 2>nul
if "%VC71DIR%"=="" (
IF %ERRORLEVEL% EQU 0 (
FOR /F "tokens=2* delims=	 " %%A IN ('REG QUERY "%MSVC71KEY%" /v ProductDir') DO SET VC71DIR=%%B
)
)
REG QUERY "%MSVC8KEY%" /v ProductDir >nul 2>nul
if "%VC8DIR%"=="" (
IF %ERRORLEVEL% EQU 0 (
FOR /F "tokens=2* delims=	 " %%A IN ('REG QUERY "%MSVC8KEY%" /v ProductDir') DO SET VC8DIR=%%B
)
)
REG QUERY "%MSVC8EXPRESSKEY%" /v ProductDir >nul 2>nul
if "%VC8EXPRESSDIR%"=="" (
IF %ERRORLEVEL% EQU 0 (
FOR /F "tokens=2* delims=	 " %%A IN ('REG QUERY "%MSVC8EXPRESSKEY%" /v ProductDir') DO SET VC8EXPRESSDIR=%%B
)
)
REG QUERY "%MSVC9KEY%" /v ProductDir >nul 2>nul
if "%VC9DIR%"=="" (
IF %ERRORLEVEL% EQU 0 (
FOR /F "tokens=2* delims=	 " %%A IN ('REG QUERY "%MSVC9KEY%" /v ProductDir') DO SET VC9DIR=%%B
)
)
REG QUERY "%MSVC9EXPRESSKEY%" /v ProductDir >nul 2>nul
if "%VC9EXPRESSDIR%"=="" (
IF %ERRORLEVEL% EQU 0 (
FOR /F "tokens=2* delims=	 " %%A IN ('REG QUERY "%MSVC9EXPRESSKEY%" /v ProductDir') DO SET VC9EXPRESSDIR=%%B
)
)
REM Look for Installed SDKs:
SET SDKROOTKEY=HKLM\SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs
SET SDK2003SP1KEY=%SDKROOTKEY%\8F9E5EF3-A9A5-491B-A889-C58EFFECE8B3
SET SDK2003SP2KEY=%SDKROOTKEY%\D2FF9F89-8AA2-4373-8A31-C838BF4DBBE1
SET SDK6KEY=HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0\WinSDKBuild
REM Just a base value to compare against
REM SET SDKVER=0
REM SET SDKMINORVER=0
REG QUERY "%SDK6KEY%" /v InstallationFolder >nul 2>nul
if "%SDKDIR%"=="" (
IF %ERRORLEVEL% EQU 0 (
FOR /F "tokens=2* usebackq delims=	 " %%A IN (`REG QUERY "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0\WinSDKBuild" /v InstallationFolder`) DO SET SDKDIR=%%B
SET SDKVER=6
)
)
REG QUERY "%SDK2003SP2KEY%" /v "Install Dir" >nul 2>nul
if "%PSDKDIR%"=="" (
IF %ERRORLEVEL% EQU 0 (
FOR /F "tokens=3* delims=	 " %%A IN ('REG QUERY "%SDK2003SP2KEY%" /v "Install Dir"') DO SET PSDKDIR=%%B
REM arbitrary, but works for me
SET PSDKVER=5
)
)
REG QUERY "%SDK2003SP1KEY%" /v "Install Dir" >nul 2>nul
if "%PSDKDIR%"=="" (
IF %ERRORLEVEL% EQU 0 (
FOR /F "tokens=3* delims=	 " %%A IN ('REG QUERY "%SDK2003SP1KEY%" /v "Install Dir"') DO SET PSDKDIR=%%B
SET PSDKVER=4
)
)
ECHO Visual C++ 6 directory: %VC6DIR%
ECHO Visual C++ 7.1 directory: %VC71DIR%
ECHO Visual C++ 8 directory: %VC8DIR%
ECHO Visual C++ 8 Express directory: %VC8EXPRESSDIR%
ECHO Visual C++ 9 directory: %VC9DIR%
ECHO Visual C++ 9 Express directory: %VC9EXPRESSDIR%
if "%SDKDIR%"=="" (
SET SDKDIR=%PSDKDIR%
SET SDKVER=%PSDKVER%
) else (
ECHO Windows SDK directory: %SDKDIR%
ECHO Windows SDK version: %SDKVER%.%SDKMINORVER%
)
ECHO Platform SDK directory: %PSDKDIR%
ECHO Platform SDK version: %PSDKVER%

For what it’s worth, it looks like guess-msvc.bat in its original form did correctly search the registry for the install locations. The batch file just couldn’t set the environment variables from that in the most useful manner. The subst command hides the spaces.

Starting MozillaBuild

You will probably want the 64-bit command line, and DevMo recommends you run it as an administrator. To save yourself some trouble, I recommend going to C:\Windows\SysWOW64 and creating a shortcut to cmd.exe on your Quick Launch bar. Then you can right-click on it any time and tell it to start the command prompt as an admin.

Next, you need to call the special batch file above, which pre-sets the SDK locations. It should also launch you into MSYS, where you can now do everything else you usually do to build Mozilla code:

  • Untarring a source tarball from ftp.mozilla.org
  • Setting a MOZCONFIG file
  • make -f client.mk configure (Note: This takes a bit longer than it used to, due to wpcapi.h and atlbase.h)
  • Building Mozilla. (For some reason, this took nearly two hours for a debug build, on this brand-new machine. Maybe my antivirus is getting in there again.)

Other notes

  • The configure script failed to recognize the 64-bit environment, and so failed to produce a 64-bit build. It did produce a functioning 32-bit build, though. Further research on true 64-bit builds of Mozilla code would be welcome – but I’m satisfied for now.
  • Building from a RAM disk – the performance aspects – I’ll report back in a future post – probably the next one.
  • The build failed make check pretty early on.