This page has detailed information on building Chromium on Windows, including tips for troubleshooting and for speeding up the build.
Build environment
Setting up the environment for Visual Studio 2010- Prerequisite software:
- Windows 7 or later.
- A 64 bit OS is highly recommended as building on 32 bit OS is constantly becoming harder, is a lot slower and is not actively maintained.
- At least 60 GB of free space in an NTFS volume. Tip: having the chromium source in a SSD drive greatly speeds build times.
- Visual Studio 2010 Professional or Standard.
- Windows 8 SDK.
- June 2010 DirectX SDK.
- (Optional) Cygwin
- Install Visual Studio 2010
- Make sure "X64 Compilers and Tools" are installed.
- Install VS2010 SP1.
- Install the Windows 8 SDK.
Note: If you install the SDK in a path different than C:\Program Files (x86)\Windows Kits\8.0 you need to set the following following environment variable:
GYP_DEFINES=windows_sdk_path="path to sdk"
- Install the June 2010 DirectX SDK
Note: If your install fails with the "Error Code: S1023" you may need to uninstall "Microsoft Visual C++ 2010 x64 Redistributable". See this tip from stackoverflow: http://stackoverflow.com/questions/4102259/directx-sdk-june-2010-installation-problems-error-code-s1023
- Patch the Windows 8 SDK to build with Visual C++ 2010
- Parts of Chromium build using the winrt headers included with the Windows 8 SDK. All the headers we use, including the WRL, can be compiled with Visual C++ 2010 with the exception of one file, asyncinfo.h. This file uses a strongly typed enum which the VS2010 compiler doesn't understand. To workaround this for the time being, a small patch needs to be applied to the Windows 8 SDK to build with the winrt headers in VS2010:
Patch for Include\winrt\asyncinfo.hIndex: asyncinfo.h =================================================================== --- asyncinfo.h +++ asyncinfo.h @@ -63,7 +63,7 @@ #pragma once #ifdef __cplusplus namespace ABI { namespace Windows { namespace Foundation { -enum class AsyncStatus { +enum /*class*/ AsyncStatus { Started = 0, Completed, Canceled,
This patch should be applied to the file "Include\winrt\asyncinfo.h" located in your Windows 8 SDK directory. If this patch is not applied, the parts of Chromium that use the Winrt headers will not compile.
Note: By default the Windows 8 SDK will install to C:\Program Files (x86)\Windows Kits\8.0\. This directory will require admin privileges to write to. Easiest way to do apply this patch is to start an administrative command prompt, cd to C:\Program Files (x86)\Windows Kits\8.0\Include\winrt\, run notepad.exe asyncinfo.h and comment out or delete the word "class" on line 66.
Note: For Googlers, this patch has already been applied to your SDK, everything should Just Work.
- (Optional) Install cygwin.
Setting up the environment for building with Visual C++ 2010 Express or Windows 7.1 SDK
- Prerequisite software:
- Windows 7 or later.
- A 64 bit OS is highly recommended as building on 32 bit OS is constantly becoming harder, is a lot slower and is not actively maintained.
- At least 60 GB of free space in an NTFS volume. Tip: having the chromium source in a SSD drive greatly speeds build times.
- Both Windows SDK 7.1 and Windows 8 SDK.
- June 2010 DirectX SDK.
- Windows Driver Kit 7.1.
- (Optional) Visual Studio 2010 Express.
- (Optional) Cygwin
- Install Visual C++ 2010 Express and Windows 7.1 SDK. The installation order is important.
- (Optional) Install Visual C++ 2010 Express
- Install Windows SDK 7.1. Make sure x64 compiler and tools are installed.
- (Optional, only if you use Visual C++ 2010 Express) Install VS2010 SP1.
- Install Visual C++ 2010 SP1 Compiler Update for the Windows SDK 7.1.
- Create an empty "C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ammintrin.h" file. The update installed on the previous step does not include this standard header for some reason. The header should declare AMD-specific SSE intrinsic functions that are not used by Chromium code. Run the following command as administrator to create the file:
echo. > C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ammintrin.h
- Install the Windows 8 SDK.
Note: If you install the SDK in a path different than C:\Program Files (x86)\Windows Kits\8.0 you need to set the following following environment variable:
GYP_DEFINES=windows_sdk_path="path to sdk"
- Patch the Windows 8 SDK to build with Visual C++ 2010
- Parts of Chromium build using the winrt headers included with the Windows 8 SDK. All the headers we use, including the WRL, can be compiled with Visual C++ 2010 with the exception of one file, asyncinfo.h. This file uses a strongly typed enum which the VS2010 compiler doesn't understand. To workaround this for the time being, a small patch needs to be applied to the Windows 8 SDK to build with the winrt headers in VS2010:
Patch for Include\winrt\asyncinfo.hIndex: asyncinfo.h =================================================================== --- asyncinfo.h +++ asyncinfo.h @@ -63,7 +63,7 @@ #pragma once #ifdef __cplusplus namespace ABI { namespace Windows { namespace Foundation { -enum class AsyncStatus { +enum /*class*/ AsyncStatus { Started = 0, Completed, Canceled,
This patch should be applied to the file "Include\winrt\asyncinfo.h" located in your Windows 8 SDK directory. If this patch is not applied, the parts of Chromium that use the Winrt headers will not compile.
Note: By default the Windows 8 SDK will install to C:\Program Files (x86)\Windows Kits\8.0\. This directory will require admin privileges to write to. Easiest way to do apply this patch is to start an administrative command prompt, cd to C:\Program Files (x86)\Windows Kits\8.0\Include\winrt\, run notepad.exe asyncinfo.h and comment out or delete the word "class" on line 66.
Note: For Googlers, this patch has already been applied to your SDK, everything should Just Work.
- Install the June 2010 DirectX SDK
Note: If your install fails with the "Error Code: S1023" you may need to uninstall "Microsoft Visual C++ 2010 x64 Redistributable". See this tip from stackoverflow: http://stackoverflow.com/questions/4102259/directx-sdk-june-2010-installation-problems-error-code-s1023
- Install Windows Driver Kit and create a system-wide environment variable named
WDK_DIR via Run...->SystemPropertiesAdvanced->Environment Variables...->New...(in System variables), with the name of WDK_DIR and the location you installed the WDK (e.g. C:\WinDDK\7600.16385.1).
- Set the following environment variable:
GYP_MSVS_VERSION=2010e
- (Optional) See Build Chromium with MSBuild below for instructions how to build from the command line, Ninja build works as well.
Automatic simplified toolchain setupThis method is an automated version of the one above. It installs the compiler, SDKs, and patches automatically, but does not install any IDE.
You can only build with ninja using these steps.
If you have Visual Studio installed, you can still use it to debug, but not to build.
Prerequisite software: - Windows 7 x64 or later. An x86 OS is unsupported.
- Get the Chromium depot_tools.
- Run "gclient" once. This ensures you have python, git, and svn available.
- Follow the steps to check out the code, using either the Subversion instructions or the Git instructions, but don't "gclient sync" yet.
- Subversion: http://dev.chromium.org/developers/how-tos/get-the-code
- Git: https://code.google.com/p/chromium/wiki/UsingGit
- Run
- python src\tools\win\toolchain\toolchain.py
- This cannot be run inside cygwin due to permissions issue.
- This will take 2-15 minutes depending on download speed, and creates a win_toolchain folder containing the tools and headers required to build Chromium.
- win_toolchain\env.bat
- cd src
- gclient sync
- ninja -C out\Debug chrome
Building Chromium
- Get the Chromium depot_tools.
- Check out the source code using a direct svn or git checkout. Do not use a tarball since it is not compatible with Windows' svn client.
- Set up the component build (or else creating chrome_dll.pdb may fail laterl) and then regenerate the build files by running "gclient runhooks --force" in a cygwin/cmd window.
- Install API keys.
- Open the chrome/chrome.sln solution file in Visual Studio and build the solution. This can take from 10 minutes to 2 hours. More likely 1 hour.
- If you just want the Chromium browser, and none of the tests, you can speed up your build by right-clicking the chrome project in the solution explorer and selecting Build. You may want to make sure this project is the Startup project (which will display as bold) by right-clicking it and selecting Set as Startup Project. This will make Chromium (as opposed to some random test) build and run when you press F5.
Accelerating the build
Be prepared: the build of whole solution can take hour(s) longer if not configured correctly.
In decreasing order of speedup:
- Use a true multicore processor, i.e. an Intel Core Duo or later (not a Pentium 4 HT).
- Use an x64 OS (otherwise incremental linking is disabled).
- Have at least 8 GB RAM. If you have less than 4 GB, you may find builds to be prohibitively slow.
- Turn on precompiled headers and the component build.
- Use
src/build/some.gyp to only load the targets you care about. - Disable your anti-virus software for .ilk, .pdb, .cc, .h files and only check for viruses on modify. Disable scanning the directory where your sources reside.
- Store and build the Chromium code on a second hard drive that does not have swap (Control Panel->System and Security->System->Advanced->Performance/Settings->Advanced->Virtual memory/Change). Compilation and linking use a lot of memory and disk I/O. It's not a good idea to have the I/O happening on the same disk that the memory manager is using for swap.
- Consider using ninja -- it's an alternative command-line build tool that's much faster than Visual Studio, especially for incremental builds.
- Reduce the number of parallel builds: avoid memory swap at any cost!. Chromium requires a lot of memory to link; if you build too many sub-projects simultaneously your PC will slow to a crawl during the linking phase because of the linkers fighting for memory. Go into MSVC's Tools\Options\Projects and Solutions\Build and Run and reduce "maximum number of parallel project builds". By default it is equal to the number of virtual processors (e.g. 8 for a quad core HT CPU). Recommended number for 12 GB of RAM is lower than 8 (see discussions here). Use an even smaller number if you have less RAM.
- You may also want to tune your include.gypi file to limit the number of cl.exe processes spawned and reduce context switches (see discussions here). For example, to limit to only 5 cl.exe and 5 linkers, the include.gypi under your home folder's .gyp should have
{
'variables': {
'msvs_multi_core_compile': 0,
},
'target_defaults': {
'msvs_settings': {
'VCCLCompilerTool': {
'AdditionalOptions': ['/MP5'],
},
},
},
}
- Defragment your hard drive regularly.
- You may want to try incremental linking if you're adventurous or using ninja. It makes linking very fast when you're working incrementally, but is somewhat flaky in Visual Studio, and you may need to do cleans after syncs to avoid spurious errors.
Optional
Rebuild / Clean:You can use Rebuild and Clean
on individual projects to rebuild them. However, because of the large
number of files generated by the build system, avoid using Rebuild All or Clean All - these do not erase everything! Instead delete the entire output directory (chrome\Debug or chrome\Release).
Build Chromium with Ninja:If you like building from the command line, consider using ninja instead - it's much faster, especially for incremental builds! The only downside is that ninja and the Visual Studio IDE don't share the intermediate object files when building.
Build Chromium using Visual Studio from the Command Line:You would need to have Visual Studio installed, but not running. Use the Visual Studio 2010 Command Prompt in your Start Menu instead of cmd. Navigate to the source directory (src/chrome) and type the following command: C:\trunk\src\chrome> devenv.exe /build Debug chrome.sln /project chrome.vcxproj
You can also use devenv.com with the same command-line. This will show the output of the various build commands, which can be useful when trying to track down errors during building.
Build Chromium with MSBuild: If you use Visual Studio 2010 or the compiler from Windows SDK 7.1 you can build Chromium with MSBuild. - Launch Visual Studio 2010 Command Prompt (for Visual Studio 2010) or Windows SDK 7.1 Command Prompt (if you don't have Visual Studio installed) instead of cmd.
- When building from Windows SDK 7.1 Command Prompt clear TARGET_CPU environment variable if you wan to build x64 targets using msbuild:
set TARGET_CPU=
- Add targets you want to build to src/build/some.gyp.
- Run gclient runhooks.
- Run the following command:
C:\trunk\src\build> msbuild.exe some.sln /p:Configuration=Debug /p:Platform=Win32 /m
You can also customize logging parameters to reduce console spew and/or redirect verbose logs to a file:
msbuild.exe some.sln /p:Configuration=Debug /p:Platform=Win32 /m /consoleloggerparameters:verbosity=minimal /l:FileLogger,Microsoft.Build.Engine;logfile="debug.log";verbosity=detailed
Using both Ninja and MSBuild:Building from MSVS is slow, but it is still nice to have intellisense and code browsing. You can have some of the best of both worlds by building in ninja, but enabling VS project files too by setting GYP_GENERATORS='ninja,msvs'. Note that if you do, it means that "gclient runhooks" and "gclient sync" takes a bit longer since we generate two sets of project files.
Official/WPO/LTCG build: To enable whole program optimization / link-time code generation, make sure to set the environment variable:
- set GYP_DEFINES=branding=Chromium buildtype=Official
- If you have the internal checkout, use Chrome instead of Chromium to get the Google Chrome resources.
- gclient runhooks
- src\build\all.sln
- Select 'Release' configuration
- Right-click on 'chrome' project and click 'Build'. You don't want to build the tests.
The WPO configuration settings are defined in release_impl_official.gypi.
Unit tests
Some unit tests (such as gfx_unittests) require at least Vista/2008 with Platform Update installed or Windows 7 to execute all of the tests completely.
Other tricks
Blog post on setting a right-hand print margin
Running Chromium
The chrome.exe executable can be found at src/build/Debug/chrome.exe or src/build/Release/chrome.exe, depending on the selected build configuration.
Because of Chromium's unique architecture, there are a number of special challenges associated with development. See Debugging Chromium for more information.
Once you're comfortable with building Chromium, read the Contributing Code page for information about writing code for Chromium and contributing it.
Packaging
If you want to package your build into a zip file, do the following:
cd /path/to/src
./chrome/tools/build/win/make_zip.sh build/Release my-chromium
This will create my-chromium.zip. You can change Release to Debug if you want to zip up the debug build instead.
Troubleshooting
Build failures on Vista
If you build on Vista, watch out for security issues. Make sure that the folder where you checked out your files is writable for users and not only for admins.
Compilation failures
Some common things to think about when you have weird compilation failures:
- If you happen to have checked out the source code before installing the build prerequisites (Visual Studio, the SDK, and all the patches), you'll need to re-generate the VS solution files by quitting Visual Studio and then running "gclient runhooks".
- Sometimes Visual Studio does the wrong thing when building Chromium and gets stuck on a bogus error. A good indication of this is if it is only failing for one person but others (including the Buildbots) are not complaining. To resolve this, try the following steps:
- Close Visual Studio.
- Sync to the tip of tree and ensure there are no conflicts ("svn status" should not show any "C"s in front of files that you've changed).
- If there were conflicts, sync again after resolving them.
- Manually erase the output directory (chrome\Debug and chrome\Release. Using the command line, you can use "erase /S /Q Debug Release" from the chrome directory to do this, or "rm -rf Debug Release" if you have Unix-like tools installed.
- Restart Visual Studio and open the Chromium solution.
- Rebuild the solution.
- If you get errors like these:
* C:\Program Files\Microsoft SDKs\Windows\v6.1\Include\unknwn.idl(108) : error MIDL2025 : syntax error : expecting ] or , near "annotation"
* browser\download\download_util.cc(469) : error C2065: 'ITaskbarList3' : undeclared identifier
You either have the wrong Platform SDK or it is incorrectly registered. Try installing the Windows 7 SDK or, if already installed, try registering the SDK manually.
- If you get errors like this:
* error C2039: '_Swap_adl' : is not a member of 'std'
Then you've likely run into a conflict between the Windows SDK and a security patch. See this MSDN blog post for more details try reinstalling Visual Studio SP1.
- If you get errors like this:
3>c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3d11shader.h(35) : error C2146: syntax error : missing ';' before identifier 'D3D11_RESOURCE_RETURN_TYPE'
3>c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3d11shader.h(35) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
3>c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3d11shader.h(35) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
3>c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3d11shader.h(37) : error C2146: syntax error : missing ';' before identifier 'D3D11_CBUFFER_TYPE'
Then make sure the DirectX headers appear first in the include search path (MSVC|Tools|Options|Projects and Solutions|VC++ Directories). After making the change the retrying the build without clobber should work.
If it still doesn't work, repeating this process probably won't help.
Cygwin access control issues
If, while building JavaScriptCore, you see errors like:
3>Error in tempfile() using /tmp/dftables-XXXXXXXX.in: Parent directory (/tmp/) is not writable
3> at /cygdrive/c/b/slave/WEBKIT~1/build/webkit/third_party/JavaScriptCore/pcre/dftables line 236
3>make: *** [chartables.c] Error 255
...it's because the Cygwin installation included in the Chromium source is having trouble mapping the NT ACL to POSIX permissions. This seems to happen when Chromium is checked out into a directory for which Cygwin can't figure out the permissions in the first place, possibly when the directory is created from within a Cygwin environment before running mkpasswd. Cygwin then imposes its own access control, which is incorrectly restrictive. As a workaround, do one of the following:
- Edit the NT permissions on third_party\cygwin\tmp to allow Modify and Write actions for Everyone and machine\Users. Cygwin is able to figure this out. Or,
- Figure out what went wrong with your checkout and try again - try doing the checkout from cmd instead of from a Cygwin shell, then verify that the permissions aren't completely blank in your Cygwin installation. Or,
- Bypass Cygwin's access control (NT's will still be in effect) by editing webkit\build\JavaScriptCore\prebuild.bat and webkit\build\WebCore\prebuild.bat to include the following line before invoking anything that uses Cygwin:
set CYGWIN=nontsec
Note: the nontsec option is not supported in cygwin 1.7 and greater.
- Edit the cygwin file /etc/fstab and add the noacl option
none /cygdrive cygdrive binary,posix=0,user,noacl 0 0
Only one of these solutions should be needed.
Native Client Doesn't Run
If you get this error when building chrome_nacl_win64:
LINK : fatal error LNK1104: cannot open file 'atlsd.lib'
It means that you didn't install the 64-bit compiler and tools as described at the top of the page.
First run of gclient fails to install python
If the first run of gclient produces the error:
svn: Can't move 'C:\Users\username\depot_tools\python_bin\tcl\Tix8.4.3\.svn\tmp\entries' to 'C:\Users\rhashimoto\depot_tools\python_bin\tcl\Tix8.4.3\.svn\entries': The file or directory is corrupted and unreadable.
... Failed to checkout python automatically.
Please visit http://python.org to download the latest python 2.x client before continuing.
You can also get the "prebacked" version used at http://src.chromium.org/chrome/trunk/tools/third_party/
See this link for instructions on turning off Windows Indexing.
Manually registering the Platform SDK- GYP picks up the proper version SDK automatically according to the 'msbuild_toolset' variable set in %USERPROFILE%\.gyp\include.gypi.
- If the variable is not set 7.0A SDK (also known as 'v100') is used. (I.e. the one that is included with Visual Studio).
- Windows 7.1 SDK is selected by setting the variable to 'Windows7.1SDK'.
|