后续会在接下来的一段时间内简单介绍下cef,cef的下载链接地址是https://cef-builds.spotifycdn.com/index.html#windows32,我用的版本是当前最新的稳定版本90.
cef没有直接提供vs工程文件,需要使用cmake来编译下,我使用的cmake版本是3.20.0
cmake --version
cmake version 3.20.0
将下载好的cef解压后放到自定义的目录里面(G:\CEF90),然后cmake .
G:\>cd CEF90
G:\CEF90>cmake .
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19042.
-- The C compiler identification is MSVC 19.27.29112.0
-- The CXX compiler identification is MSVC 19.27.29112.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) at CMakeLists.txt:207 (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:
G:/CEF90
For compatibility, CMake is ignoring the variable.
This warning is for project developers. Use -Wno-dev to suppress it.
-- *** CEF CONFIGURATION SETTINGS ***
-- Generator: Visual Studio 16 2019
-- Platform: Windows
-- Project architecture: x86_64
-- Binary distribution root: G:/CEF90
-- Visual Studio ATL support: ON
-- CEF sandbox: ON
-- Standard libraries: comctl32.lib;rpcrt4.lib;shlwapi.lib;ws2_32.lib;Advapi32.lib;dbghelp.lib;Delayimp.lib;OleAut32.lib;PowrProf.lib;Propsys.lib;psapi.lib;SetupAPI.lib;Shell32.lib;version.lib;wbemuuid.lib;winmm.lib
-- Compile defines: __STDC_CONSTANT_MACROS;__STDC_FORMAT_MACROS;WIN32;_WIN32;_WINDOWS;UNICODE;_UNICODE;WINVER=0x0601;_WIN32_WINNT=0x601;NOMINMAX;WIN32_LEAN_AND_MEAN;_HAS_EXCEPTIONS=0;PSAPI_VERSION=1;CEF_USE_SANDBOX;CEF_USE_ATL
-- Compile defines (Debug):
-- Compile defines (Release): NDEBUG;_NDEBUG
-- C compile flags: /MP;/Gy;/GR-;/W4;/WX;/wd4100;/wd4127;/wd4244;/wd4481;/wd4512;/wd4701;/wd4702;/wd4996;/Zi
-- C compile flags (Debug): /MTd;/RTC1;/Od
-- C compile flags (Release): /MT;/O2;/Ob2;/GF
-- C++ compile flags: /MP;/Gy;/GR-;/W4;/WX;/wd4100;/wd4127;/wd4244;/wd4481;/wd4512;/wd4701;/wd4702;/wd4996;/Zi
-- C++ compile flags (Debug): /MTd;/RTC1;/Od
-- C++ compile flags (Release): /MT;/O2;/Ob2;/GF
-- Exe link flags: /MANIFEST:NO;/LARGEADDRESSAWARE
-- Exe link flags (Debug): /DEBUG
-- Exe link flags (Release):
-- Shared link flags:
-- Shared link flags (Debug): /DEBUG
-- Shared link flags (Release):
-- CEF Binary files: chrome_elf.dll;libcef.dll;libEGL.dll;libGLESv2.dll;snapshot_blob.bin;v8_context_snapshot.bin;swiftshader;d3dcompiler_47.dll
-- CEF Resource files: chrome_100_percent.pak;chrome_200_percent.pak;resources.pak;icudtl.dat;locales
-- Configuring done
-- Generating done
-- Build files have been written to: G:/CEF90
会在目录下生成ALL_BUILD.vcxproj,双击打开,发现只有x64的,需要手动配置下x86的
新增x86的配置项后,需要先编译ZERO_CHECK工程,然后libcef_dll_wrapper,编译cefsimple项目的时候,需要把链接--输入--附加依赖项里面的libcef_dll_wrapper.lib的路径设置下,还需要把生成事件--生成后事件--命令行清空,这样就可以编译通过了
里面的测试工程cefsimple好像debug下有问题,release是好的,不清楚原因
使用的时候需要把CEF90/Resources里面的文件拷贝到release目录,这样一个简单的cef示例就好了