编译最后一个支持XP的CEF3(v2623)

来源:互联网 发布:植物生长算法程序 编辑:程序博客网 时间:2024/05/17 06:21
为什么要自己编译cef3?因为官网提供的没有加入mp3支持。其实编译的过程主要步骤都是根据官网的说明的:https://bitbucket.org/chromiumembedded/cef/wiki/MasterBuildQuickStart.md,我在这里还要啰嗦的原因是因为编译过程中出现了一些错误,这里主要是说明错误的解决方法,也是给自己做个备忘吧。我的环境是win7 + vs201 5 +  Windows 10.0.10586 SDK。
一、创建相应目录:
d:\cef3\
     automate\
     chromium_git\
     depot_tools\
二、下载 文件depot_tools.zip,并解压到目录d:\cef3\depot_tools
三、运行update_depot_tools.bat
cd d:\cef3\depot_tools
update_depot_tools.bat
四、将d:\cef3\depot_tools添加到环境变量PATH
五、下载文件automate-git.py放到目录d:\cef3\automate\
六、在目录d:\cef3\chromium_git\下创建文件update.bat,文件内容为:
set CEF_USE_GN=0
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
set GYP_DEFINES=buildtype=Official proprietary_codecs=1 ffmpeg_branding=Chrome
set GYP_GENERATORS=ninja,msvs-ninja
set GYP_MSVS_VERSION=2015
python ..\automate\automate-git.py --download-dir=d:\cef3\chromium_git --depot-tools-dir=d:\cef3\depot_tools --branch=2623 --no-distrib --no-buil

我们可以看到这个文件内容和官网稍微有点不一样,因为官网的说明是用的GN,而我们要编译的是旧版CEF3,还是用旧版的GYP。
--branch=2623指我们要下载的源码版本

七、运行下载源代码
cd d:\cef3\chromium_git
update.bat
这一步是需要翻墙的,建议花钱买一个VPN,这样稳定。

一旦下好了源码,就可以开始下面的编译步骤了。
八、在目录d:\cef3\chromium_git\chromium\src\cef\下创建文件create.bat,文件内容为:
set CEF_USE_GN=0
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
set GYP_DEFINES=buildtype=Official proprietary_codecs=1 ffmpeg_branding=Chrome
set GYP_GENERATORS=ninja,msvs-ninja
set GYP_MSVS_VERSION=2015
call cef_create_projects.bat

九、因为用的是VS2015,所以得加个编译选项,不然会出现在XP下运行崩溃的情况。这个问题的详解请看:http://blog.csdn.net/qsy2000/article/details/52915317
打开文件D:\cef3\chromium_git\chromium\src\build\common.gypi,找到如下的内容:
['OS=="win" and MSVS_VERSION == "2015"', {
            'msvs_settings': {
              'VCCLCompilerTool': {
                'AdditionalOptions': [
                  # Work around crbug.com/526851, bug in VS 2015 RTM compiler.
                  '/Zc:sizedDealloc-',
                ],
              },
            },
          }],
然后在'/Zc:sizedDealloc-',后面加上 '/Zc:threadSafeInit-',。

十、运行create.bat生成编译配置文件
cd d:\cef3\chromium_git\chromium\src\cef
create.bat

十一、编译。编译之前先把系统语言改成英语,然后重启电脑,不然。会出现一些字符集之类的错误。
cd d:\cef3\chromium_git\chromium\src
ninja -C out\Release

--------------------------------------------------------------------------------------
下面是编译过程中出现错误的解决办法。
一、error C2220: warning treated as error - no 'object' file generated
。。。。。。
warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits

按提示的文件名和行数,找到相关的常量,在后面加i64,如原来是1,则改成1i64。
在我这里这个错误提示的是文件D:\cef3\chromium_git\chromium\src\google_apis\gaia\oauth2_token_service.cc中的第313行,
 原来为:int64_t exponential_backoff_in_seconds = 1 << retry_num;
 改为:int64_t exponential_backoff_in_seconds = 1i64 << retry_num;

 二、d:\cef3\chromium_git\chromium\src\ui\gl\gl_bindings_skia_in_process.cc(860): err
or C2679: binary '=': no operator found which takes a right-hand operand of type
 'overloaded-function' (or there is no acceptable conversion)
d:\cef3\chromium_git\chromium\src\third_party\skia\include\gpu\gl\grglinterface.
h(116): note: could be 'GrGLInterface::GLPtr<GrGLBufferDataProc> &GrGLInterface:
:GLPtr<GrGLBufferDataProc>::operator =(GrGLInterface::GLPtr<GrGLBufferDataProc>
&&)'
d:\cef3\chromium_git\chromium\src\third_party\skia\include\gpu\gl\grglinterface.
h(116): note: or       'GrGLInterface::GLPtr<GrGLBufferDataProc> &GrGLInterface:
:GLPtr<GrGLBufferDataProc>::operator =(const GrGLInterface::GLPtr<GrGLBufferData
Proc> &)'
。。。。。。

打开d:\cef3\chromium_git\chromium\src\ui\gl\gl_bindings_skia_in_process.cc文件,把提示有错误的函数参数类型前面都加上Gr,
如原来为 GLenum的,改成GrGLenum,GLintptr 改为GrGLintptr等等,如为void*的,改成GrGLvoid,如这里提示的第860行:
functions->fBufferData = StubGLBufferData;
那么就搜索
StubGLBufferData的定义地方:
GLvoid GR_GL_FUNCTION_TYPE StubGLBufferData(GLenum target,
                                            GLsizeiptr size,
                                            const void* data,
                                            GLenum usage) {
改成这样:
GLvoid GR_GL_FUNCTION_TYPE StubGLBufferData(GrGLenum target,
                                            GrGLsizeiptr size,
                                            const GrGLvoid* data,
                                            GrGLenum usage) {
其它的函数也是这样修改即可。

 三、d:\cef3\chromium_git\chromium\src\third_party\swiftshader\include\egl\eglext.h(1
19): error C4430: missing type specifier - int assumed. Note: C++ does not suppo
rt default-int
d:\cef3\chromium_git\chromium\src\third_party\swiftshader\include\egl\eglext.h(1
19): error C2143: syntax error: missing ',' before '*'
d:\cef3\chromium_git\chromium\src\third_party\swiftshader\include\egl\eglext.h(1
20): error C2061: syntax error: identifier 'EGLAttrib'

打开d:\cef3\chromium_git\chromium\src\third_party\swiftshader\include\egl\eglext.h,
在62行typedef int ptr_t EGLAttribKHR;   后添加一行typedef int ptr_t EGLAttrib;

四、ffmpeg.lib(ffmpeg.wavdec.obj) : error LNK2001: unresolved external symbol _ff_w6
4_guid_data
libcef.dll : fatal error LNK1120: 1 unresolved externals

打开文件D:\cef3\chromium_git\chromium\src\out\Release\obj\third_party\ffmpeg\ffmpeg.ninja,按wavdec关键字搜索,
1、找到
build obj\third_party\ffmpeg\libavformat\ffmpeg.wavdec.obj: cc $
    ..\..\third_party\ffmpeg\libavformat\wavdec.c
这两行,复制一份插到行build obj\third_party\ffmpeg\libavformat\ffmpeg.wavdec.obj: cc $前面,
并把wavdec改成w64,结果变成:
build obj\third_party\ffmpeg\libavformat\ffmpeg.w64.obj: cc $
    ..\..\third_party\ffmpeg\libavformat\w64.c
build obj\third_party\ffmpeg\libavformat\ffmpeg.wavdec.obj: cc $
    ..\..\third_party\ffmpeg\libavformat\wavdec.c
2、继续找到行:obj\third_party\ffmpeg\libavformat\ffmpeg.wavdec.obj $
复制成两行,并修改成如下:
obj\third_party\ffmpeg\libavformat\ffmpeg.w64.obj $
obj\third_party\ffmpeg\libavformat\ffmpeg.wavdec.obj $

以上每一步修改完成后,就继续 运行
ninja -C out\Release进行编译即可。

编译成功之后,运行out\Release\cefclient.exe,打开http://html5test.com/,检查看看MP3项是否打上勾

cef3-2623(mp3).rar

2 0
原创粉丝点击