目次
文書の過去の版を表示しています。
Chromium Embedded Framework
Chromium Embedded Framework(CEF) は、Chromiumベースのブラウザを他のアプリケーションに埋め込むための単純なフレームワークである。
フレームワークのダウンロード
chromiumembedded / cef — Bitbucket の Binary Distributions - CEF Automated Builds より cef_binary_3.3626.1886.g162fdec_linux64.tar.bz2(フレームワークのバイナリディストリビューション)をダウンロードする。
フレームワーク入門
セットアップ
クロスプラットフォームのオープンソースビルドシステム CMake をインストールする。バージョン2.8.12.1以降が必要。
$ sudo dnf install cmake
Python をインストールする。バージョン 2.x が必要。
$ sudo dnf install python3
プラットフォーム固有のビルドツールをインストールする。
$ sudo dnf groupinstall "Development Tools" $ sudo dnf install gcc-c++ gtk2-devel gtkglext-devel
ダウンロードページから、Git コマンドラインツールを使用して、cef-project のソースコードをダウンロードする。
$ git clone https://bitbucket.org/chromiumembedded/cef-project.git
ビルド
Chromium Embedded Framework (CEF) のバイナリディストリビューションを解凍する。
$ tar jxvf cef_binary_3.3626.1886.g162fdec_linux64.tar.bz2
Makefile を生成する。
$ cd cef_binary_3.3626.1886.g162fdec_linux64 $ mkdir build && cd build $ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ..
-- The C compiler identification is GNU 8.2.1
-- The CXX compiler identification is GNU 8.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) at CMakeLists.txt:187 (find_package):
Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
CMake variable CEF_ROOT is set to:
/home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64
For compatibility, CMake is ignoring the variable.
This warning is for project developers. Use -Wno-dev to suppress it.
-- Performing Test COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS
-- Performing Test COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS - Success
-- Performing Test COMPILER_SUPPORTS_NO_LITERAL_SUFFIX
-- Performing Test COMPILER_SUPPORTS_NO_LITERAL_SUFFIX - Success
-- Performing Test COMPILER_SUPPORTS_NO_NARROWING
-- Performing Test COMPILER_SUPPORTS_NO_NARROWING - Success
-- *** CEF CONFIGURATION SETTINGS ***
-- Generator: Unix Makefiles
-- Platform: Linux
-- Project architecture: x86_64
-- Build type: Debug
-- Binary distribution root: /home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64
-- CEF sandbox: ON
-- Standard libraries: X11
-- Compile defines: __STDC_CONSTANT_MACROS;__STDC_FORMAT_MACROS;_FILE_OFFSET_BITS=64;CEF_USE_SANDBOX
-- Compile defines (Debug):
-- Compile defines (Release): NDEBUG
-- C compile flags: -fno-strict-aliasing;-fPIC;-fstack-protector;-funwind-tables;-fvisibility=hidden;--param=ssp-buffer-size=4;-pipe;-pthread;-Wall;-Werror;-Wno-missing-field-initializers;-Wno-unused-parameter;-Wno-error=comment;-Wno-comment;-m64;-march=x86-64 -std=c99;-Wno-unused-local-typedefs
-- C compile flags (Debug): -O0;-g
-- C compile flags (Release): -O2;-fdata-sections;-ffunction-sections;-fno-ident;-U_FORTIFY_SOURCE;-D_FORTIFY_SOURCE=2
-- C++ compile flags: -fno-strict-aliasing;-fPIC;-fstack-protector;-funwind-tables;-fvisibility=hidden;--param=ssp-buffer-size=4;-pipe;-pthread;-Wall;-Werror;-Wno-missing-field-initializers;-Wno-unused-parameter;-Wno-error=comment;-Wno-comment;-m64;-march=x86-64 -fno-exceptions;-fno-rtti;-fno-threadsafe-statics;-fvisibility-inlines-hidden;-std=gnu++11;-Wsign-compare;-Wno-literal-suffix;-Wno-narrowing
-- C++ compile flags (Debug): -O0;-g
-- C++ compile flags (Release): -O2;-fdata-sections;-ffunction-sections;-fno-ident;-U_FORTIFY_SOURCE;-D_FORTIFY_SOURCE=2
-- Exe link flags: -fPIC;-pthread;-Wl,--disable-new-dtags;-Wl,--fatal-warnings;-Wl,-rpath,.;-Wl,-z,noexecstack;-Wl,-z,now;-Wl,-z,relro;-m64
-- Exe link flags (Debug):
-- Exe link flags (Release): -Wl,-O1;-Wl,--as-needed;-Wl,--gc-sections
-- Shared link flags: -fPIC;-pthread;-Wl,--disable-new-dtags;-Wl,--fatal-warnings;-Wl,-rpath,.;-Wl,-z,noexecstack;-Wl,-z,now;-Wl,-z,relro;-m64
-- Shared link flags (Debug):
-- Shared link flags (Release): -Wl,-O1;-Wl,--as-needed;-Wl,--gc-sections
-- CEF Binary files: chrome-sandbox;libcef.so;libEGL.so;libGLESv2.so;natives_blob.bin;snapshot_blob.bin;v8_context_snapshot.bin;swiftshader
-- CEF Resource files: cef.pak;cef_100_percent.pak;cef_200_percent.pak;cef_extensions.pak;devtools_resources.pak;icudtl.dat;locales
-- Configuring done
-- Generating done
-- Build files have been written to: /home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/build
CEF をビルドする。
$ make -j4
In file included from /home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/libcef_dll/ctocpp/value_ctocpp.h:25,
from /home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/libcef_dll/cpptoc/accessibility_handler_cpptoc.cc:16:
/home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/libcef_dll/ctocpp/ctocpp_ref_counted.h:78:27: エラー: ‘cfi-icall’ attribute directive ignored [-Werror=attributes]
void UnderlyingAddRef() const {
^~~~~
/home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/libcef_dll/ctocpp/ctocpp_ref_counted.h:86:28: エラー: ‘cfi-icall’ attribute directive ignored [-Werror=attributes]
bool UnderlyingRelease() const {
^~~~~
/home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/libcef_dll/ctocpp/ctocpp_ref_counted.h:95:30: エラー: ‘cfi-icall’ attribute directive ignored [-Werror=attributes]
bool UnderlyingHasOneRef() const {
^~~~~
/home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/libcef_dll/ctocpp/ctocpp_ref_counted.h:104:37: エラー: ‘cfi-icall’ attribute directive ignored [-Werror=attributes]
bool UnderlyingHasAtLeastOneRef() const {
^~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [libcef_dll_wrapper/CMakeFiles/libcef_dll_wrapper.dir/build.make:219: libcef_dll_wrapper/CMakeFiles/libcef_dll_wrapper.dir/cpptoc/accessibility_handler_cpptoc.cc.o] エラー 1
make[2]: *** 未完了のジョブを待っています....
In file included from /home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/libcef_dll/ctocpp/command_line_ctocpp.h:26,
from /home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/libcef_dll/cpptoc/app_cpptoc.cc:19:
/home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/libcef_dll/ctocpp/ctocpp_ref_counted.h:78:27: エラー: ‘cfi-icall’ attribute directive ignored [-Werror=attributes]
void UnderlyingAddRef() const {
^~~~~
/home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/libcef_dll/ctocpp/ctocpp_ref_counted.h:86:28: エラー: ‘cfi-icall’ attribute directive ignored [-Werror=attributes]
bool UnderlyingRelease() const {
^~~~~
/home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/libcef_dll/ctocpp/ctocpp_ref_counted.h:95:30: エラー: ‘cfi-icall’ attribute directive ignored [-Werror=attributes]
bool UnderlyingHasOneRef() const {
^~~~~
/home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/libcef_dll/ctocpp/ctocpp_ref_counted.h:104:37: エラー: ‘cfi-icall’ attribute directive ignored [-Werror=attributes]
bool UnderlyingHasAtLeastOneRef() const {
^~~~~
In file included from /home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/libcef_dll/ctocpp/scheme_registrar_ctocpp.h:25,
from /home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/libcef_dll/cpptoc/app_cpptoc.cc:20:
/home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/libcef_dll/ctocpp/ctocpp_scoped.h:184:14: エラー: ‘cfi-icall’ attribute directive ignored [-Werror=attributes]
void* ptr) {
^
cc1plus: all warnings being treated as errors
make[2]: *** [libcef_dll_wrapper/CMakeFiles/libcef_dll_wrapper.dir/build.make:232: libcef_dll_wrapper/CMakeFiles/libcef_dll_wrapper.dir/cpptoc/app_cpptoc.cc.o] エラー 1
make[1]: *** [CMakeFiles/Makefile2:91: libcef_dll_wrapper/CMakeFiles/libcef_dll_wrapper.dir/all] エラー 2
make: *** [Makefile:84: all] エラー 2
ビルドエラーが発生してコンパイルが停止してしまった。
CEF Forum • Building new version fails with attribute directive ignored に同じケースのエラーの対処が載っていたので、それを参考に ../cmake/cef_variables.cmake を修正する。
$ vi ../cmake/cef_variables.cmake
- cmake/cef_variables.cmake
# # Linux configuration. # if(OS_LINUX) # Platform-specific compiler/linker flags. set(CEF_LIBTYPE SHARED) list(APPEND CEF_COMPILER_FLAGS -fno-strict-aliasing # Avoid assumptions regarding non-aliasing of objects of different types -fPIC # Generate position-independent code for shared libraries -fstack-protector # Protect some vulnerable functions from stack-smashing (security feature) -funwind-tables # Support stack unwinding for backtrace() -fvisibility=hidden # Give hidden visibility to declarations that are not explicitly marked as visible --param=ssp-buffer-size=4 # Set the minimum buffer size protected by SSP (security feature, related to stack-protector) -pipe # Use pipes rather than temporary files for communication between build stages -pthread # Use the pthread library -Wall # Enable all warnings # -Werror # Treat warnings as errors -Wno-missing-field-initializers # Don't warn about missing field initializers -Wno-unused-parameter # Don't warn about unused parameters -Wno-error=comment # Don't warn about code in comments -Wno-comment # Don't warn about code in comments )
※-Werrorコンパイラオプションを無効にする。
再度 CEF をビルドする。
$ make -j4
CMake Warning (dev) at CMakeLists.txt:187 (find_package):
Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
CMake variable CEF_ROOT is set to:
/home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64
For compatibility, CMake is ignoring the variable.
This warning is for project developers. Use -Wno-dev to suppress it.
〜省略〜
In file included from /home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/libcef_dll/ctocpp/value_ctocpp.h:25,
from /home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/libcef_dll/cpptoc/accessibility_handler_cpptoc.cc:16:
/home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/libcef_dll/ctocpp/ctocpp_ref_counted.h:78:27: 警告: ‘cfi-icall’ attribute directive ignored [-Wattributes]
void UnderlyingAddRef() const {
^~~~~
〜省略〜
[ 99%] Building CXX object tests/ceftests/CMakeFiles/ceftests.dir/views/textfield_unittest.cc.o
[100%] Building CXX object tests/ceftests/CMakeFiles/ceftests.dir/views/window_unittest.cc.o
[100%] Linking CXX executable Debug/ceftests
*** Run the following command manually to set SUID permissions ***
EXE="/home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/build/tests/cefclient/Debug/chrome-sandbox" && sudo -- chown root:root $EXE && sudo -- chmod 4755 $EXE
[100%] Built target cefclient
*** Run the following command manually to set SUID permissions ***
EXE="/home/tomoyan/my_projects/cef_binary_3.3626.1886.g162fdec_linux64/build/tests/ceftests/Debug/chrome-sandbox" && sudo -- chown root:root $EXE && sudo -- chmod 4755 $EXE
[100%] Built target ceftests
※警告: ‘cfi-icall’ attribute directive ignored [-Wattributes] 警告は出るがコンパイルは通る様になった。
cef-project のビルド
cef-project のダウンロード
$ git clone https://bitbucket.org/chromiumembedded/cef-project.git
Makefile の生成
cmake を実行すると cef_binary のダウンロードをしてから Makefile を生成してくれます。
$ cd cef-project $ mkdir build && cd build $ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
-- The C compiler identification is GNU 8.2.1
-- The CXX compiler identification is GNU 8.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Downloading /home/tomoyan/my_projects/cef-project/third_party/cef/cef_binary_3.3538.1852.gcb937fc_linux64.tar.bz2.sha1...
-- Downloading /home/tomoyan/my_projects/cef-project/third_party/cef/cef_binary_3.3538.1852.gcb937fc_linux64.tar.bz2...
-- [download 0% complete]
-- [download 1% complete]
-- [download 2% complete]
〜省略〜
-- [download 98% complete]
-- [download 99% complete]
-- [download 100% complete]
-- Extracting /home/tomoyan/my_projects/cef-project/third_party/cef/cef_binary_3.3538.1852.gcb937fc_linux64.tar.bz2...
CMake Warning (dev) at CMakeLists.txt:54 (find_package):
Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
CMake variable CEF_ROOT is set to:
/home/tomoyan/my_projects/cef-project/third_party/cef/cef_binary_3.3538.1852.gcb937fc_linux64
For compatibility, CMake is ignoring the variable.
This warning is for project developers. Use -Wno-dev to suppress it.
-- Performing Test COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS
-- Performing Test COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS - Success
-- Performing Test COMPILER_SUPPORTS_NO_LITERAL_SUFFIX
-- Performing Test COMPILER_SUPPORTS_NO_LITERAL_SUFFIX - Success
-- Performing Test COMPILER_SUPPORTS_NO_NARROWING
-- Performing Test COMPILER_SUPPORTS_NO_NARROWING - Success
-- Found PythonInterp: /usr/bin/python (found version "2.7.15")
-- Downloading clang-format from Google Storage...
0> File tools/buildtools/linux64/clang-format exists and SHA1 matches. Skipping.
Success!
Downloading 1 files took 0.005556 second(s)
-- *** CEF CONFIGURATION SETTINGS ***
-- Generator: Unix Makefiles
-- Platform: Linux
-- Project architecture: x86_64
-- Build type: Release
-- Binary distribution root: /home/tomoyan/my_projects/cef-project/third_party/cef/cef_binary_3.3538.1852.gcb937fc_linux64
-- CEF sandbox: ON
-- Standard libraries: X11
-- Compile defines: __STDC_CONSTANT_MACROS;__STDC_FORMAT_MACROS;_FILE_OFFSET_BITS=64;CEF_USE_SANDBOX
-- Compile defines (Debug):
-- Compile defines (Release): NDEBUG
-- C compile flags: -fno-strict-aliasing;-fPIC;-fstack-protector;-funwind-tables;-fvisibility=hidden;--param=ssp-buffer-size=4;-pipe;-pthread;-Wall;-Werror;-Wno-missing-field-initializers;-Wno-unused-parameter;-Wno-error=comment;-Wno-comment;-m64;-march=x86-64 -std=c99;-Wno-unused-local-typedefs
-- C compile flags (Debug): -O0;-g
-- C compile flags (Release): -O2;-fdata-sections;-ffunction-sections;-fno-ident;-U_FORTIFY_SOURCE;-D_FORTIFY_SOURCE=2
-- C++ compile flags: -fno-strict-aliasing;-fPIC;-fstack-protector;-funwind-tables;-fvisibility=hidden;--param=ssp-buffer-size=4;-pipe;-pthread;-Wall;-Werror;-Wno-missing-field-initializers;-Wno-unused-parameter;-Wno-error=comment;-Wno-comment;-m64;-march=x86-64 -fno-exceptions;-fno-rtti;-fno-threadsafe-statics;-fvisibility-inlines-hidden;-std=gnu++11;-Wsign-compare;-Wno-literal-suffix;-Wno-narrowing
-- C++ compile flags (Debug): -O0;-g
-- C++ compile flags (Release): -O2;-fdata-sections;-ffunction-sections;-fno-ident;-U_FORTIFY_SOURCE;-D_FORTIFY_SOURCE=2
-- Exe link flags: -fPIC;-pthread;-Wl,--disable-new-dtags;-Wl,--fatal-warnings;-Wl,-rpath,.;-Wl,-z,noexecstack;-Wl,-z,now;-Wl,-z,relro;-m64
-- Exe link flags (Debug):
-- Exe link flags (Release): -Wl,-O1;-Wl,--as-needed;-Wl,--gc-sections
-- Shared link flags: -fPIC;-pthread;-Wl,--disable-new-dtags;-Wl,--fatal-warnings;-Wl,-rpath,.;-Wl,-z,noexecstack;-Wl,-z,now;-Wl,-z,relro;-m64
-- Shared link flags (Debug):
-- Shared link flags (Release): -Wl,-O1;-Wl,--as-needed;-Wl,--gc-sections
-- CEF Binary files: chrome-sandbox;libcef.so;libEGL.so;libGLESv2.so;natives_blob.bin;snapshot_blob.bin;v8_context_snapshot.bin;swiftshader
-- CEF Resource files: cef.pak;cef_100_percent.pak;cef_200_percent.pak;cef_extensions.pak;devtools_resources.pak;icudtl.dat;locales
-- Configuring done
-- Generating done
-- Build files have been written to: /home/tomoyan/my_projects/cef-project/build
cef_variables.cmake の修正
ビルドエラーにならない様に cef_variables.cmake を修正する。
$ vi ../third_party/cef/cef_binary_3.3538.1852.gcb937fc_linux64/cmake/cef_variables.cmake
- ../third_party/cef/cef_binary_3.3538.1852.gcb937fc_linux64/cmake/cef_variables.cmake
# -Werror # Treat warnings as errors
※-Werrorをコメントアウトする。
ビルド
cef-project をビルドする。
$ make -j4
CMake Warning (dev) at CMakeLists.txt:54 (find_package):
Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
CMake variable CEF_ROOT is set to:
/home/tomoyan/my_projects/cef-project/third_party/cef/cef_binary_3.3538.1852.gcb937fc_linux64
For compatibility, CMake is ignoring the variable.
This warning is for project developers. Use -Wno-dev to suppress it.
-- Downloading clang-format from Google Storage...
0> File tools/buildtools/linux64/clang-format exists and SHA1 matches. Skipping.
Success!
〜省略〜
[100%] Building CXX object third_party/cef/cef_binary_3.3538.1852.gcb937fc_linux64/tests/ceftests/CMakeFiles/ceftests.dir/views/window_unittest.cc.o
[100%] Linking CXX executable Release/ceftests
*** Run the following command manually to set SUID permissions ***
EXE="/home/tomoyan/my_projects/cef-project/build/third_party/cef/cef_binary_3.3538.1852.gcb937fc_linux64/tests/ceftests/Release/chrome-sandbox" && sudo -- chown root:root $EXE && sudo -- chmod 4755 $EXE
[100%] Built target ceftests
SUIDアクセス許可を設定
ビルドが終わったら指示にしたがって、手動で次のコマンドを実行して SUID アクセス許可を設定する。
$ EXE="/home/tomoyan/my_projects/cef-project/build/third_party/cef/cef_binary_3.3538.1852.gcb937fc_linux64/tests/ceftests/Release/chrome-sandbox" && sudo -- chown root:root $EXE && sudo -- chmod 4755 $EXE