当前位置: 代码迷 >> 综合 >> Window10下VS2019编译 Chromium
  详细解决方案

Window10下VS2019编译 Chromium

热度:45   发布时间:2024-01-13 00:15:55.0

按照官方的操作说明(https://bitbucket.org/chromiumembedded/cef/wiki/MasterBuildQuickStart.md#markdown-header-windows-setup)编译会出现不少问题

1、首先如果安装的是版本的(Python 3.0以上),在调用(create.bat)生成工程会有一个接口报错,编译会被阻塞

unicode("", "utf-8")这个函数在python 3.0版本已经被废除了,因此需要切换道python 2.7才能编译通过,在安装python 2.1以后需要重新配置python的系统路径,确保优先运行低版本的python

2、在编译skia的时候会遇到如下错误:

In file included from ../../cef/libcef/renderer/blink_glue.cc:12:
In file included from ../..\third_party/blink/public/web/web_document.h:40:
In file included from ../..\third_party/blink/public/web/web_frame.h:35:
In file included from ../..\cc/paint/paint_canvas.h:13:
In file included from ../..\cc/paint/paint_image.h:18:
In file included from ../..\third_party/skia/include/core/SkImage.h:11:
In file included from ../../third_party/skia\include/core/SkImageEncoder.h:12:
In file included from ../../third_party/skia\include/core/SkBitmap.h:11:
In file included from ../../third_party/skia\include/core/SkColor.h:11:
In file included from ../../third_party/skia\include/core/SkImageInfo.h:11:
In file included from ../../third_party/skia\include/core/SkColorSpace.h:11:
In file included from ../../third_party/skia\include/core/SkRefCnt.h:11:
../../third_party/skia\include/core/SkTypes.h(192,14): error: #include resolved using non-portable Microsoft search rules as: ../..\cc/paint/../../skia/config/SkUserConfig.h [-Werror,-Wmicrosoft-include]
    #include SK_USER_CONFIG_HEADER
             ^
<command line>(61,31): note: expanded from here
#define SK_USER_CONFIG_HEADER "../../skia/config/SkUserConfig.h"

查阅资料,主要原因是不同编译器查找头文件规则不同,修改SkTypes.h 191行

// IWYU pragma: begin_exports
#undef SK_USER_CONFIG_HEADER
#if defined (SK_USER_CONFIG_HEADER)
    #include SK_USER_CONFIG_HEADER
#else
    #include "include/config/SkUserConfig.h"
#endif

再编译时这个问题就消失了

3、出现SkDrawLooper is unsupported为问题

In file included from ../../cc/layers/recording_source.cc:13:
In file included from ../..\cc/layers/content_layer_client.h:11:
In file included from ../..\cc/paint/display_item_list.h:18:
In file included from ../..\cc/paint/discardable_image_map.h:19:
In file included from ../..\cc/paint/paint_flags.h:13:
../..\third_party/skia/include/core/SkDrawLooper.h(20,2): error: "SkDrawLooper is unsupported"
#error "SkDrawLooper is unsupported"

查看了skia的源码SkDrawLooper.h,明确写了不支持,不知道为什么还要include这个文件

/** \class SkDrawLooper
    DEPRECATED: No longer supported in Skia.
*/
class SK_API SkDrawLooper : public SkFlattenable {
public:

把paint_flags.h中包含文件去掉

#include "third_party/skia/include/core/SkColorFilter.h"
//#include "third_party/skia/include/core/SkDrawLooper.h"

会出错

In file included from ../..\cc/paint/paint_filter.h:13:
../..\cc/paint/paint_flags.h(142,29): error: use of undeclared identifier 'SkDrawLooper'
  ALWAYS_INLINE const sk_sp<SkDrawLooper>& getLooper() const {
                            ^
../..\cc/paint/paint_flags.h(145,38): error: use of undeclared identifier 'SkDrawLooper'
  ALWAYS_INLINE void setLooper(sk_sp<SkDrawLooper> looper) {
                                     ^
../..\cc/paint/paint_flags.h(187,9): error: use of undeclared identifier 'SkDrawLooper'
  sk_sp<SkDrawLooper> draw_looper_;
        ^
../..\cc/paint/paint_flags.h(165,21): error: use of undeclared identifier 'SkDrawLooper'
    if (const sk_sp<SkDrawLooper>& looper = getLooper())

看来还是调用这个类,只好修改SkDrawLooper.h,将报错内容注释掉

/*
#ifndef SK_SUPPORT_LEGACY_DRAWLOOPER
#error "SkDrawLooper is unsupported"
#endif
*/

这一块就可以编译通过,不过新的问题又来了

../../cc/paint/paint_shader.cc(463,47): error: no matching member function for call to 'makeShader'
        cached_shader_ = image_.GetSkImage()->makeShader(
                         ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
../../third_pa

  相关解决方案