vs2015上的html可以编译,libcef编译使用--使用VS2015
1.背景
现在好多客户端程序都内嵌浏览器,有的用于实现界面,有的用于实现一些特殊功能,比如网易云音乐,QQ客户端,微信桌面客户端等。如果要内嵌浏览器,传统的方法是加入自带的IE webbrowser activex控件,但是IE对html5标准的支持不是很好,无法完成一些最新的功能。此时webkit就是最好的选择,可是webkit是一个很复杂的工程,编译也非常麻烦。好在有人替我们完成这个工作。有个叫libcef的库,实现了对webkit的封装,我们只需要直接调用就可以了,从而往我们的程序嵌入webkit浏览器,实现我们需要的功能。上面说到的那三个软件都用到了libcef这个库,在这些程序的安装目录下我们可以看到libcef.dll,libEGL.dll等dll文件。
2.生成VS工程文件
从https://cefbuilds.com/下载预编译好的二进制包,我下载的是cef_binary_3.2526.1346.g1f86d24_windows32.7z,2526分支的32位版本。然后解压到本地,比如我的是D:\SDK\cef。虽然需要的dll以及两个lib文件已经帮我们编译好了,但此时libcef还不能直接使用,因为我们还需要libcef_dll_wrapper.lib这个文件,而这个需要我们自己编译,如果没有这个的话,我们运行里面的cefsimple:
C++
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include
#include "cefsimple/simple_app.h"
#include "include/cef_sandbox_win.h"
// When generating projects with CMake the CEF_USE_SANDBOX value will be defined
// automatically if using the required compiler version. Pass -DUSE_SANDBOX=OFF
// to the CMake command-line to disable use of the sandbox.
// Uncomment this line to manually enable sandbox support.
// #define CEF_USE_SANDBOX 1
#if defined(CEF_USE_SANDBOX)
// The cef_sandbox.lib static library is currently built with VS2013. It may not
// link successfully with other VS versions.
#pragma comment(lib, "cef_sandbox.lib")
#endif
// Entry point function for all processes.
int APIENTRY wWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow) {
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// Enable High-DPI support on Windows 7 or newer.
CefEnableHighDPISupport();
void* sandbox_info = NULL;
#if defined(CEF_USE_SANDBOX)
// Manage the life span of the sandbox information object. This is necessary
// for sandbox support on Windows. See cef_sandbox_win.h for complete details.
CefScopedSandboxInfo scoped_sandbox;
sandbox_info = scoped_sandbox.sandbox_info();
#endif
// Provide CEF with command-line arguments.
CefMainArgs main_args(hInstance);
// SimpleApp implements application-level callbacks. It will create the first
// browser instance in OnContextInitialized() after CEF has initialized.
CefRefPtr app(new SimpleApp);
// CEF applications have multiple sub-processes (render, plugin, GPU, etc)
// that share the same executable. This function checks the command-line and,
// if this is a sub-process, executes the appropriate logic.
int exit_code = CefExecuteProcess(main_args, app.get(), sandbox_info);
if (exit_code >= 0) {
// The sub-process has completed so return here.
return exit_code;
}
// Specify CEF global settings here.
CefSettings settings;
#if !defined(CEF_USE_SANDBOX)
settings.no_sandbox = true;
#endif
// Initialize CEF.
CefInitialize(main_args, settings, app.get(), sandbox_info);
// Run the CEF message loop. This will block until CefQuitMessageLoop() is
// called.
CefRunMessageLoop();
// Shut down CEF.
CefShutdown();
return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include
#include "cefsimple/simple_app.h"
#include "include/cef_sandbox_win.h"
// When generating projects with CMake the CEF_USE_SANDBOX value will be defined
// automatically if using the required compiler version. Pass -DUSE_SANDBOX=OFF
// to the CMake command-line to disable use of the sandbox.
// Uncomment this line to manually enable sandbox support.
// #define CEF_USE_SANDBOX 1
#if defined(CEF_USE_SANDBOX)
// The cef_sandbox.lib static library is currently built with VS2013. It may not
// link successfully with other VS versions.
#pragma comment(lib, "cef_sandbox.lib")
#endif
// Entry point function for all processes.
intAPIENTRYwWinMain(HINSTANCEhInstance,
HINSTANCEhPrevInstance,
LPTSTRlpCmdLine,
intnCmdShow){
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// Enable High-DPI support on Windows 7 or newer.
CefEnableHighDPISupport();
void*sandbox_info=NULL;
#if defined(CEF_USE_SANDBOX)
// Manage the life span of the sandbox information object. This is necessary
// for sandbox support on Windows. See cef_sandbox_win.h for complete details.
CefScopedSandboxInfoscoped_sandbox;
sandbox_info=scoped_sandbox.sandbox_info();
#endif
// Provide CEF with command-line arguments.
CefMainArgsmain_args(hInstance);
// SimpleApp implements application-level callbacks. It will create the first
// browser instance in OnContextInitialized() after CEF has initialized.
CefRefPtrapp(newSimpleApp);
// CEF applications have multiple sub-processes (render, plugin, GPU, etc)
// that share the same executable. This function checks the command-line and,
// if this is a sub-process, executes the appropriate logic.
intexit_code=CefExecuteProcess(main_args,app.get(),sandbox_info);
if(exit_code>=0){
// The sub-process has completed so return here.
returnexit_code;
}
// Specify CEF global settings here.
CefSettingssettings;
#if !defined(CEF_USE_SANDBOX)
settings.no_sandbox=true;
#endif
// Initialize CEF.
CefInitialize(main_args,settings,app.get(),sandbox_info);
// Run the CEF message loop. This will block until CefQuitMessageLoop() is
// called.
CefRunMessageLoop();
// Shut down CEF.
CefShutdown();
return0;
}
会报如下错误:
SeverityCodeDescriptionProjectFileLine
ErrorLNK2019unresolved external symbol "int __cdecl CefExecuteProcess(class CefMainArgs const &,class CefRefPtr,void *)" (?CefExecuteProcess@@YAHABVCefMainArgs@@V?$CefRefPtr@VCefApp@@@@PAX@Z) referenced in function _wWinMain@16cefsampleD:\vs2015\cefsample\cefsample\Source.obj1
ErrorLNK2019unresolved external symbol "bool __cdecl CefInitialize(class CefMainArgs const &,class CefStructBase const &,class CefRefPtr,void *)" (?CefInitialize@@YA_NABVCefMainArgs@@ABV?$CefStructBase@UCefSettingsTraits@@@@V?$CefRefPtr@VCefApp@@@@PAX@Z) referenced in function _wWinMain@16cefsampleD:\vs2015\cefsample\cefsample\Source.obj1
ErrorLNK2019unresolved external symbol "void __cdecl CefShutdown(void)" (?CefShutdown@@YAXXZ) referenced in function _wWinMain@16cefsampleD:\vs2015\cefsample\cefsample\Source.obj1
ErrorLNK2019unresolved external symbol "void __cdecl CefRunMessageLoop(void)" (?CefRunMessageLoop@@YAXXZ) referenced in function _wWinMain@16cefsampleD:\vs2015\cefsample\cefsample\Source.obj1
ErrorLNK2019unresolved external symbol "void __cdecl CefEnableHighDPISupport(void)" (?CefEnableHighDPISupport@@YAXXZ) referenced in function _wWinMain@16cefsampleD:\vs2015\cefsample\cefsample\Source.obj1
ErrorLNK2019unresolved external symbol "public: __thiscall SimpleApp::SimpleApp(void)" (??0SimpleApp@@QAE@XZ) referenced in function _wWinMain@16cefsampleD:\vs2015\cefsample\cefsample\Source.obj1
ErrorLNK11206 unresolved externalscefsampleD:\vs2015\cefsample\Debug\cefsample.exe1
1
2
3
4
5
6
7
8
SeverityCodeDescriptionProjectFileLine
ErrorLNK2019unresolvedexternalsymbol"int __cdecl CefExecuteProcess(class CefMainArgs const &,class CefRefPtr,void *)"(?CefExecuteProcess@@YAHABVCefMainArgs@@V?$CefRefPtr@VCefApp@@@@PAX@Z)referencedinfunction_wWinMain@16cefsampleD:\vs2015\cefsample\cefsample\Source.obj1
ErrorLNK2019unresolvedexternalsymbol"bool __cdecl CefInitialize(class CefMainArgs const &,class CefStructBase const &,class CefRefPtr,void *)"(?CefInitialize@@YA_NABVCefMainArgs@@ABV?$CefStructBase@UCefSettingsTraits@@@@V?$CefRefPtr@VCefApp@@@@PAX@Z)referencedinfunction_wWinMain@16cefsampleD:\vs2015\cefsample\cefsample\Source.obj1
ErrorLNK2019unresolvedexternalsymbol"void __cdecl CefShutdown(void)"(?CefShutdown@@YAXXZ)referencedinfunction_wWinMain@16cefsampleD:\vs2015\cefsample\cefsample\Source.obj1
ErrorLNK2019unresolvedexternalsymbol"void __cdecl CefRunMessageLoop(void)"(?CefRunMessageLoop@@YAXXZ)referencedinfunction_wWinMain@16cefsampleD:\vs2015\cefsample\cefsample\Source.obj1
ErrorLNK2019unresolvedexternalsymbol"void __cdecl CefEnableHighDPISupport(void)"(?CefEnableHighDPISupport@@YAXXZ)referencedinfunction_wWinMain@16cefsampleD:\vs2015\cefsample\cefsample\Source.obj1
ErrorLNK2019unresolvedexternalsymbol"public: __thiscall SimpleApp::SimpleApp(void)"(??0SimpleApp@@QAE@XZ)referencedinfunction_wWinMain@16cefsampleD:\vs2015\cefsample\cefsample\Source.obj1
ErrorLNK11206unresolvedexternalscefsampleD:\vs2015\cefsample\Debug\cefsample.exe1
都是些 referenced in function _wWinMain@16的错误。
要编译libcef_dll_wrapper.lib文件,需要我们去生成VS工程文件,然后用VS打开编译。此时我们需要用到cmake软件。如下图所示打开cmake软件,设置代码目录以及工程文件生成目录:
接着点击Configure,选择编译器,我用的是默认VS2015自带的:
然后点击Generate即在cef目录下生成VS工程文件:
如下图,目录下已经生成了cef.sln解决方案文件,此时我们打开cef.sln文件
可以看到该解决方案下有5个工程:
编译libcef_dll_wrapper工程即可得到libcef_dll_wrapper.lib文件,然后我们编译运行示例工程cefclient,即可看到一个简单的浏览器,很简单吧。
vs2015上的html可以编译,libcef编译使用--使用VS2015相关推荐
- windows平台下载编译好的webrtc代码vs2015
windows平台下载编译好的webrtc代码vs2015 编译好的源码工程地址: https://github.com/hujianhua888/webrtc_vs2015,工程目录如下,包含所有 ...
- python3 llvmlite源码_将Paddle-Lite在树莓派上源码编译及编译python预测库
新手使用Paddle-Lite 第一篇博客,第一次接触树莓派,把我的经历说一说. 一.为什么选Paddle-Lite? 因为我第一次接触人工智能,PaddlePaddle官网https://www.p ...
- 如何在Eclipse 3.3上安装jadclipse[java的反编译工具] 收藏
如何在Eclipse 3.3上安装jadclipse[java的反编译工具] 收藏 jad是java的反编译工具,是命令行执行,反编译出来的源文件可读性较高.可惜用起来不太方便.还好 找到eclips ...
- ubuntu上搭建rtt开发环境并编译2K1000 bsp
系统介绍: RT-Thread是一个集实时操作系统(RTOS)内核.中间件组件的物联网操作系统: rt-thread特点: 资源占用极低,超低功耗设计,组件丰富,支持高性能应用,跨平台:类似vxWor ...
- VS2015上配置opencv2.4.11
VS2015上配置opencv2.4.11版方法总结 最近给电脑重装了系统,需要的软件各种装.今天阅读了很多网上的博客,几经波折完成了opencv的配置.配置opencv与其他函数包或者软件相比算是麻 ...
- WIN10 + Tensorflow1.12 + Cmake编译 + Bazel编译
文章转自: https://www.wandouip.com/t5i38311/ 几篇值得参考的博文: [1] https://blog.csdn.net/robothn/article/detail ...
- vs2017 c语言 需要的插件,刚刚装了VS2017, 然后原来在VS2015上写的C++程
qq_3616545962092017-11-18 VS 2017 上面的svn 突然不能用了 qq_3949066412362018-12-14 win7(64位旗舰版)visual studio ...
- php windows 编译,Windows编译PHP7.2拓展
准备工作https://github.com/Microsoft/php-sdk-binary-tools下载PHP-SDK(在右边的"clone or download"点击,选 ...
- python在线编译-在线编译python
广告关闭 2017年12月,云+社区对外发布,从最开始的技术博客到现在拥有多个社区产品.未来,我们一起乘风破浪,创造无限可能. 尝试通过源码自己编译 python,使用的系统是 ubuntu14.04 ...
- build 之前执行task_浅谈VS编译自定义编译任务—MSBuild Task(csproject)-阿里云开发者社区...
在上一篇浅谈.NET编译时注入(C#-->IL)中我们简单的反编译查看了几种c#语法糖和PostSharp在编译成IL时为我做的MSIL注入.紧接着在这节,要来看的就是MSBuild Task. ...
最新文章
- Captaris Workflow 6.0 EventService 执行效率低下的排除。
- P1049 装箱问题
- 【数据分析】关于学习SQL的五个常见问题?
- java运算级别_java运算符优先级别
- java单例模式代码
- ESPHome 和 Home Assistant传感器之TMT6000 环境光握手
- Telephone--短信发送/接收流程
- JDT操作AST重构if块
- 黑马linux系统编程
- Zabbix如何配置告警短信?
- 请将文件MP_verify_xxxxxx.txt上传至填写域名或路径指向的web服务器(或虚拟主机)的目录 曲线救国
- 1.初接触思科模拟器
- 实习生招聘丨DolphinDB星臾计划
- 通俗理解ip地址,子网掩码,网关
- CodeBlocks使用小技巧
- 阿里副总裁人设“翻车”:30 岁成 AI 顶尖科学家,但我很懒
- 再见SpringMVC!字节跳动正式启动2021届秋季校招!不可思议!
- 《果壳中的宇宙》回顾
- windows操作系统安装单机版mongodb
- 智能小车红外避障模块----使用教程