CEF用户使用手册

1. CEF下载

以CEF90为例,可以直接点击以下链接访问龙芯CEF下载页面进行下载:龙芯CEF下载网页。另外,还可以通过终端使用wget命令进行下载操作:

[loongson@bogon ~]$ wget -c http://ftp.loongnix.cn/cef/LoongArch/90.0.4430.93/cef_binary_90.6.5+g7a604aa+chromium-90.0.4430.93_linuxla64.tar.gz

2. CEF的使用

解压CEF

[loongson@bogon ~]$ tar -xvf cef_binary_90.6.5+g7a604aa+chromium-90.0.4430.93_linuxla64.tar.gz

CEF解压成功后得到CEF目录,可使用CEF目录中的库和头文件进行CEF相关的开发

目录结构如下

[loongson@bogon ~/cef_binary_90.6.5+g7a604aa+chromium-90.0.4430.93_linuxla64]$ ls
cef_paths2.gypi  cmake           include     LICENSE.txt  Release    tests
cef_paths.gypi   CMakeLists.txt  libcef_dll  README.txt   Resources


- include
目录是CEF的头文件,使用CEF开发时需引用这些头文件并调用里面的api函数接口。
- Release
该目录存放着libcef.so动态库,使用CEF开发时需要链接该动态库
- tests
该目录放的是CEF官方基于CEF开发的一些示例和测试样例
- libcef_dll
该目录是CEF的封装的接口
- Resource
该目录放的是一些资源文件
- cmake
该目录放着编译相关的文件

在tests目录中,CEF官方提供了基于CEF开发的应用示例cefsimple和cefclient,用户可以参考这两个应用示例的实现和官方文档,使用CEF进行开发。

2.1. 实例一:cefsimple

1) 安装所需要的软件包

[loongson@bogon ~]$ sudo apt install cmake ninja-build

2) 进入到cefsimple目录中

[loongson@bogon ~]$ cd cef_binary_90.6.5+g7a604aa+chromium-90.0.4430.93_linuxla64/tests/cefsimple

这基于CEF开发的应用示例,该目录中的文件如下:

[loongson@bogon ~/cef_binary_90.6.5+g7a604aa+chromium-90.0.4430.93_linuxla64/tests/cefsimple]$ ls
cefsimple_linux.cc  simple_app.cc  simple_handler.cc  simple_handler_linux.cc
CMakeLists.txt      simple_app.h   simple_handler.h

通过CMakeLists.txt文件,可知该应用使用cmake进行管理,可以使用cmake和ninja工具编译出这两个示例程序,这两个命令分别属于cmake包和ninja-build包。

3) 在CEF目录中执行命令,使用cmake工具生成ninja的工程文件build.ninja

[loongson@bogon ~/cef_binary_90.6.5+g7a604aa+chromium-90.0.4430.93_linuxla64/tests/cefsimple]$ cd ../../

[loongson@bogon ~/cef_binary_90.6.5+g7a604aa+chromium-90.0.4430.93_linuxla64]$ cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release

4) 使用ninja工具进行编译构建出Release版本,编译cefsimple

[loongson@bogon ~/cef_binary_90.6.5+g7a604aa+chromium-90.0.4430.93_linuxla64]$ ninja cefsimple

// cefsimple构建完成的标志如下所示:

[184/184] Linking CXX executable tests/cefsimple/Release/cefsimple

*** Run the following command manually to set SUID permissions ***
EXE="/home/loongson/cef_binary_90.6.5+g7a604aa+chromium-90.0.4430.93_linuxla64/tests/cefsimple/Release/chrome-sandbox" && sudo -- chown root:root $EXE && sudo -- chmod 4755 $EXE

5) 运行编译好的cefsimple程序

[loongson@bogon ~/cef_binary_90.6.5+g7a604aa+chromium-90.0.4430.93_linuxla64]$ cd tests/cefsimple/Release

[loongson@bogon ~/cef_binary_90.6.5+g7a604aa+chromium-90.0.4430.93_linuxla64/tests/cefsimple/Release]$ ./cefsimple --url="www.loongson.cn"

该命令表示使用cefsimple应用,加载www.loongson.cn链接

执行程序后得到如下所示:

Image

2.2. 实例二 cefclient

1) 在CEF目录中执行命令,使用cmake工具生成ninja的工程文件build.ninja

[loongson@bogon ~]$ cd cef_binary_90.6.5+g7a604aa+chromium-90.0.4430.93_linuxla64

[loongson@bogon ~/cef_binary_90.6.5+g7a604aa+chromium-90.0.4430.93_linuxla64]$ cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release

2) 使用ninja工具进行编译构建出Release版本,编译cefclient

[loongson@bogon ~/cef_binary_90.6.5+g7a604aa+chromium-90.0.4430.93_linuxla64]$ ninja cefclient

// cefclient构建完成的标志如下所示:

[242/242] Linking CXX executable tests/cefclient/Release/cefclient

*** Run the following command manually to set SUID permissions ***
EXE="/home/loongson/cef_binary_90.6.5+g7a604aa+chromium-90.0.4430.93_linuxla64/tests/cefclient/Release/chrome-sandbox" && sudo -- chown root:root $EXE && sudo -- chmod 4755 $EXE

3) 运行编译好的cefclient程序

[loongson@bogon ~/cef_binary_90.6.5+g7a604aa+chromium-90.0.4430.93_linuxla64]$ cd tests/cefclient/Release

[loongson@bogon ~/cef_binary_90.6.5+g7a604aa+chromium-90.0.4430.93_linuxla64/tests/cefclient/Release]$ ./cefclient --url="www.loongson.cn"

执行程序后得到如下所示:

Image

©龙芯开源社区 all right reserved,powered by Gitbook文档更新时间: 2023-06-19 11:41:37

results matching ""

    No results matching ""

    results matching ""

      No results matching ""