VS2015编译CEF的MD版本

需要用CEF的MD版本,但官方默认是编译MT版本,探索了一下MD版本的编译,做个小结

若不知MD和MT的区别,请移步Microsoft Docs

参考了CEF官方文档,摘录:

Dynamic Linking (with a CEF DLL)

If you prefer to link CEF with your application dynamically then the process is faster. CEF provides a binary distribution on the downloads page that contains everything you need to link CEF with your application including source code for the libcef_dll_wrapper project. If your application does not use the /MT flag then you will need to rebuild the libcef_dll_wrapper project with the same flags as your application. Unlike with static linking, you will not need to rebuild all of CEF or Chromium in order to do this.

  1. Download a CEF binary release from the project downloads page.
  2. Run CMake with the additional -DCEF_RUNTIME_LIBRARY_FLAG=/MD command-line flag (/MD can be replaced with other flags as appropriate).
  3. Open cef.sln in Visual Studio.
  4. Right click on the libcef_dll_wrapper project and choose the "Project Only -> Build Only libcef_dll_wrapper" option.

Sandbox support (linking cef_sandbox.lib) is only possible when your application is built with the /MT flag.

 对应实践:
1.下载解压CEF,我这里使用的是cef_binary_3.3578.1863.gbf8cff2_windows64.tar.bz2;
2.下载安装CMake,我这里使用的是cmake-3.13.2-win64-x64.msi,Generate之前需要修改CMake的两项,需要把CEF_RUNTIME_LIBRARY_FLAG由/MT改成/MD,并把USE_SANDBOX取消勾选,因为官方也说了,这个看起来负责安全的沙箱,只能用/MT编;
3.用VS15打开了生成的cef.sln...;
4.这里只需要编libcef_dll_wrapper就可以了,生成的还是静态库,不要改成动态链接库,其他几个demo、test的项目也可以一块编了,生成解决方案遇到的全部问题:
(1)error C2039: “unique_ptr”: 不是“std”的成员,解决方法加#include
(2)error C2220: 警告被视为错误 - 没有生成“object”文件,解决方法配置属性=》C/C++=》常规=》将警告视为错误改为否 (/WX-)
(3)error C2001: 常量中有换行符,原因有日文,解决方法删掉...

你可能感兴趣的:(Web)