VS2015编译CEF的MD版本

本文详细介绍了如何从源码编译使用动态链接库(MD)版本的CEF( Chromium Embedded Framework),并解决编译过程中遇到的常见问题,如包含memory头文件、调整警告设置和清理日文字符。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

需要用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 <memory>
(2)error C2220: 警告被视为错误 - 没有生成“object”文件,解决方法配置属性=》C/C++=》常规=》将警告视为错误改为否 (/WX-)
(3)error C2001: 常量中有换行符,原因有日文,解决方法删掉...

cef3 mfc 测试demo windows vs2015工程 windows vs2015中mfc开发的嵌入式浏览器DEMO,完整工程,包含了库文件libcef_dll_wrapper.lib和libcef.lib。 1、库版本cef_binary_3.2704.1414.g185cd6c_windows32,引用于http://opensource.spotify.com/cefbuilds/index.html。 如需要其它版本VS2013/vs2017等编译的库,可以去opensource.spotify.com下载自行编译编译需要安装 cmake. 2、工程引用于https://github.com/xiaonaiquan/CEF3,github上缺少了上面的库。 3、此工程为MFC工程,只适用于WINDOWS。opensource.spotify.com中的原装示例不是MFC的,而是标准windows库的。 使用的cef版本cef_binary_3.2704.1414.g185cd6c_windows32 此demo编译VS2015 实现了C++和js交互 使用CEF时,加载的网页,如果里面有链接,指定target=”_blank”,则会弹出一个新的浏览窗口。如果想禁掉,让新页面在当前浏览窗口中显示,可以在browser进程的handler里重写CefLifeSpanHandler的OnBeforePopup方法,用browser的mainFrame加载popup请求的url 使用flash的方法在我优快云博客中,把代码加入进来就可以了。 browser和render进程分别继承CefAPP test.html是网页测试用例 解决flash有黑框 : http://blog.youkuaiyun.com/zhuhongshu/article/details/77482985 实现下载功能(是网页上触发下载,并不是MFC触发下载) GO按钮增加了快捷键回车 增加F5刷新 增加前进和后退按钮 增加右键和F12开发者选项调试网页 增加cookie 参考 : https://github.com/xiaonaiquan/CEF3 http://opensource.spotify.com/cefbuilds/index.html
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Coye1023

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值