Linux平台下cef&chromium编译--加入对h264的支持

背景:

    在cef上进行二次开发,发现默认不只支持h264解码。需要重新编译chromium解决。

步骤:

    https://bitbucket.org/chromiumembedded/cef/wiki/MasterBuildQuickStart.md#markdown-header-linux-setup 为官方编译指导。主要步骤已经十分详细。下面红字部分补充一些实际编译遇到的问题。

 

前提:

需要fq

需要fq

需要fq!!

需要好用的vpn,或者ssr 加 proxifier 实现全局代理。具体教程网上很多。

 

Linux Setup

What's Required

  • Ubuntu 16.04 LTS 64-bit is recommended. Building with other versions or distros has not been tested and may experience issues.
  • At least 6GB of RAM and 40GB of free disk space.(内存实在不够,可以用swap凑,4g还是起码要的,否则极度影响编译速度。 硬盘空间最好60g以上,40g可能不够)
  • Approximately 2 hours with a fast internet connection (25Mbps) and fast build machine (2.6Ghz+, 4+ logical cores).(虚拟机,单核也没问题,就是耗时巨长。。

Step-by-step Guide

In this example "~" is "/home/marshall". Note that in some cases the absolute path must be used. Environment variables described in this section can be added to your "~/.profile" or "~/.bashrc" file to persist them across sessions.

整体主要是用户和权限问题,需要非root用户执行

1. Create the following directories. 

mkdir ~/code
mkdir ~/code/automate
mkdir ~/code/chromium_git

2. Download and run "~/code/install-build-deps.sh" to install build dependencies. Answer Y (yes) to all of the questions.

cd ~/code
sudo apt-get install curl
curl 'https://chromium.googlesource.com/chromium/src/+/master/build/install-build-deps.sh?format=TEXT' | base64 -d > install-build-deps.sh
chmod 755 install-build-deps.sh
sudo ./install-build-deps.sh --no-arm --no-chromeos-fonts --no-nacl

3. Install the "libgtkglext1-dev" package required by the cefclient sample application.

sudo apt-get install libgtkglext1-dev

4. Download "~/code/depot_tools" using Git.

cd ~/code
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

5. Add the "~/code/depot_tools" directory to your PATH. Note the use of an absolute path here.

export PATH=/home/marshall/code/depot_tools:$PATH

6. Download the "~/automate/automate-git.py" script.

cd ~/code/automate
wget https://bitbucket.org/chromiumembedded/cef/raw/master/tools/automate/automate-git.py

7. Create the "~/code/chromium_git/update.sh" script with the following contents.

(环境变量主要是为了加入对h264解码的支持,chromium默认是不支持h264的)

#!/bin/bash
export DEPOT_TOOLS_UPDATE=0
export CEF_USE_GN=1
export GN_DEFINES="is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome"
export GYP_DEFINES=buildtype=Official

python ../automate/automate-git.py --download-dir=/home/marshall/code/chromium_git --depot-tools-dir=/home/marshall/code/depot_tools --no-distrib --no-build

(--branch=3683  指定对应要下载的分支版本  --force-clean 最好加上,可以去除残留)

Give it executable permissions.

cd ~/code/chromium_git
chmod 755 update.sh

Run the "update.sh" script and wait for CEF and Chromium source code to download. CEF source code will be downloaded to "~/code/chromium_git/cef" and Chromium source code will be downloaded to "~/code/chromium_git/chromium/src". After download completion the CEF source code will be copied to "~/code/chromium_git/chromium/src/cef".

cd ~/code/chromium_git
./update.sh

8. Create the "~/code/chromium_git/chromium/src/cef/create.sh" script with the following contents.】

(环境变量主要是为了加入对h264解码的支持,chromium默认是不支持h264的)

#!/bin/bash
export DEPOT_TOOLS_UPDATE=0
export CEF_USE_GN=1
export GN_DEFINES="is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome use_jumbo_build=true"
export GYP_DEFINES=buildtype=Official
export GN_DEFINES=use_jumbo_build=true
./cef_create_projects.sh

Give it executable permissions.

cd ~/code/chromium_git/chromium/src/cef
chmod 755 create.sh

Run the "create.sh" script to create Ninja project files. Repeat this step if you change the project configuration or add/remove files in the GN configuration (BUILD.gn file).

cd ~/code/chromium_git/chromium/src/cef
./create.sh

9. Create a Debug build of CEF/Chromium using Ninja. Edit the CEF source code at "~/code/chromium_git/chromium/src/cef" and repeat this step multiple times to perform incremental builds while developing. Note the additional "chrome_sandbox" target required by step 10.

cd ~/code/chromium_git/chromium/src
ninja -C out/Debug_GN_x64 cef chrome_sandbox

10. Set up the Linux SUID sandbox.

# This environment variable should be set at all times.
export CHROME_DEVEL_SANDBOX=/usr/local/sbin/chrome-devel-sandbox

# This command only needs to be run a single time.
cd ~/code/chromium_git/chromium/src
sudo BUILDTYPE=Debug_GN_x64 ./build/update-linux-sandbox.sh

11. Run the cefclient sample application.

cd ~/code/chromium_git/chromium/src
./out/Debug_GN_x64/cefclient

相关问题:
1、________ running 'cipd ensure -log-level error -root /home/z/code/chromium_git/chromium -ensure-file /tmp/tmpkunrfR.ensure' in '.'
CIPD selfupdate failed. Trying to bootstrap the CIPD client from scratch...
[P21376 19:08:21.295 client.go:309 W] RPC failed transiently. Will retry in 1s    {"error":"failed to send request: Post https://chrome-infra-packages.appspot.com/prpc/cipd.Repository/ResolveVersion: proxyconnect tcp: net/http: TLS handshake timeout", "host":"chrome-infra-packages.appspot.com", "method":"ResolveVersion", "service":"cipd.Repository", "sleepTime":"1s"
解决:查看代理设置 默认https是优先选择的,如果https不可用,直接设置为export https_proxy=http://

2、FAILED: gen/mojo/public/js/mojo_bindings_lite.js
解决:安装jdk

3、clang++: error: unable to execute command: Killed
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 9.0.0 (trunk 351477)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: ../../third_party/llvm-build/Release+Asserts/bin
clang++: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang++: note: diagnostic msg: 
解决:内存不够,增加swap空间
sudo fallocate -l 6G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
开机自动挂载swap:
使用 vi 或 nano 在 /etc/fstab 文件底部添加如下内容:
/swapfile none swap sw 0 0

4、WARNING: subprocess '"git" "-c" "core.deltaBaseCacheLimit=2g" "fetch" "origin"' in   
解决:
 在对应目录执行 git remote prune origin(同步远程仓库)

CEF (Chromium Embedded Framework) 是基于 Chromium 的嵌入式框架,支持在应用程序中嵌入 Chromium 浏览器。CEF 支持平台编译,包括 Windows、Linux 和 macOS。针对 ARM64 平台编译,可以参考以下步骤: 1. 安装依赖项 在 Ubuntu 20.04 上,可以使用以下命令安装必要的依赖项: ``` sudo apt-get update sudo apt-get install -y build-essential cmake git libgtk-3-dev libssl-dev libudev-dev pkg-config ``` 2. 下载 CEF 源代码 从 CEF 官方网站下载最新的源代码,并解压到本地目录。 ``` wget https://cef-builds.spotifycdn.com/cef_binary_89.0.18%2Bgb62bacf%2Bchromium-89.0.4389.82_linuxarm64_minimal.tar.bz2 tar xvf cef_binary_89.0.18+gb62bacf+chromium-89.0.4389.82_linuxarm64_minimal.tar.bz2 ``` 3. 配置 CMake 进入 CEF 源代码目录,执行以下命令来配置 CMake: ``` cd cef_binary_89.0.18+gb62bacf+chromium-89.0.4389.82_linuxarm64_minimal mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=Release -DCEF_USE_SANDBOX=OFF -DCEF_USE_ATL=OFF -DCEF_USE_GNOME_KEYRING=OFF .. ``` 其中,`-DCMAKE_BUILD_TYPE=Release` 指定编译为 Release 模式,`-DCEF_USE_SANDBOX=OFF` 关闭沙箱,`-DCEF_USE_ATL=OFF` 关闭 ATL 支持,`-DCEF_USE_GNOME_KEYRING=OFF` 关闭 GNOME Keyring 支持。 4. 编译 CEF 执行以下命令进行编译: ``` make -j4 ``` 其中,`-j4` 指定使用 4 个线程进行编译。根据硬件配置和编译选项的不同,编译时间可能会有所不同。 5. 集成 CEF 编译完成后,在 build 目录下会生成相应的 CEF 库文件和示例程序。可以根据需要将 CEF 集成到自己的项目中。具体的集成方式可以参考 CEF 官方文档。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值