编译Chromium 源码

本文档提供了 Chromium 在 Linux 环境下的详细编译指南,包括获取源代码、配置构建环境、编译选项及常见问题解决办法等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

LinuxBuildInstructions  
Build instructions for Linux 
Linux
Updated  Jan 30, 2012 by  thakis@chromium.org

Overview

Due mostly to its history and its complexity, Chromium uses a nonstandard set of custom tools to check out and build. Here's an overview of the steps you'll run:

  1. gclient. A checkout involves pulling nearly 100 different SVN repositories of code. This process is managed with a tool called gclient.
  2. gyp. The cross-platform build configuration system is called gyp, and on Linux it generates Makefiles. Running gyp is analogous to the./configure step seen in most other software.
  3. make. The actual build itself uses GNU make.
  4. We don't provide any sort of "install" step.

Getting a checkout

Linux users often prefer to use Git. We have a page on how to check out the main tree with Git, but note that you still will need to understand and run all of gclient and gyp anyway.

First Time Build Bootstrap

  • Make sure your dependencies are up to date by running the install-build-deps.sh script:
    .../chromium/src  $ ./build/install-build-deps.sh 

Configuring

After gclient sync finishes, it will run gyp automatically to generate the Makefiles. You can re-run gyp yourself as build/gyp_chromium.

gyp supports a minimal amount of build configuration via the -D flag.

./build/gyp_chromium -Dflag1=value1 -Dflag2=value2
  • gcc warnings. By default we fail to build if there are any compiler warnings. If you're getting warnings, can't build because of that, but just want to get things done, you can specify -Dwerror= to turn that off.
  • ChromeOS-Dchromeos=1 builds the ChromeOS version of Chrome. This is not all of ChromeOS (see the ChromiumOS page for full build instructions), this is just the slightly tweaked version of the browser that runs on that system. Its not designed to be run outside of ChromeOS and some features won't work, but compiling on your Linux desktop can be useful for certain types of development and testing.

Compilation

The weird "src/" directory is an artifact of gclient. Start with:

$ cd src

Build just chrome

$ make chrome

Faster builds

To do a parallel build, add -jX where X is the number of make processes to start up. This is useful for multiple-core machines or machines using distcc.

Build every tests

$ make

The above builds all libraries and tests in all components. It will take hours.

Specifying other target names to restrict the build to just what you're interested in. To build just the simplest unit test:

$ make base_unittests

Or you can specify the explicit file you want to build:

$ make out/Debug/chrome

GCC 4.6 is not supported yet. You may run into some build errors (and patches are welcome to fix them). Please see http://crbug.com/80071before you proceed.

Clang builds

Information about building with Clang can be found here.

Output

Executables are written in src/out/Debug/ for Debug builds, and src/out/Release/ for Release builds.

Release mode

Add BUILDTYPE=Release to the make invocation:

$ make BUILDTYPE=Release

Seeing the commands

If you want to see the actual commands that make is invoking, add V=1 to the make invocation.

$ make V=1

This is useful if, for example, you are debugging gyp changes, or otherwise need to see what make is actually doing.

Clean builds

All built files are put into the out/ directory, so to start over with a clean build, just:

rm -rf out

Troubleshooting

If you see make: *** No targets specified and no makefile found. Stop., you probably need to run gyp again. See the "Configuring" steps above.

Linker Crashes

If, during the final link stage:

  LINK(target) out/Debug/chrome

You get an error like:

collect2: ld terminated with signal 6 Aborted terminate called after throwing an instance of 'std::bad_alloc'

collect2: ld terminated with signal 11 [Segmentation fault], core dumped 

you are probably running out of memory when linking. Try one of:

  1. Use the gold linker
  2. Build on a 64-bit computer
  3. Build in Release mode (debugging symbols require a lot of memory)
  4. Build as shared libraries (note: this build is for developers only, and may have broken functionality)
Most of these are described on the  LinuxFasterBuilds page.

Advanced Features

Next Steps

If you want to contribute to the effort toward a Chromium-based browser for Linux, please check out the Linux Development page for more information.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值