Cef,chromium the abbreviation for the Embedded framework. CEF's official website introduces simplicity: A simple framework for embedding Chromium browser windows in other applications. Specifically, a framework that embeds browser functionality (page rendering, JS execution) into other applications. Interested to see here: HTTPS://BITBUCKET.ORG/CHROMIUMEMBEDDED/CEF.
The advantage of CEF is that the development of web and native hybrid applications is very convenient, much better than calling the Windows IE components, at least with the application to carry a stable version of the Chrominum, and IE version too much, your application relies on the user's operating system, various compatibility pits ...
It took a long time, and finally ran through the small example of cefsimple. Record the process.
Tools
My pairing:
- VS 2013
- CMake 3.4.1
- CEF 3.2357.1271 (binary package for csdn download channel)
I extracted CEF Binary for Windows into this directory: D:\PROJECTS\CEF_BINARY_3.2357.1271.G8E0674E_WINDOWS32, we use Cefdir instead.
There is no VS project and solution in CEF binary now, you have to generate it yourself.
Environment configuration and compilation process
The cefsimple example relies on libcef_dll_wrapper and needs to compile the Libcef_dll project first.
Compiling Libcef_dll
- Download CMake 3.4.1 (cmake-3.4.1-win32-x86.zip) to https://cmake.org/download/
- Unzip to a directory, I here is E:\software\cmake-3.4.1-win32-x86, back useful your-cmake-dir refer to. Open the command line (Cmd.exe) and execute the "set path=your-cmake-dir/bin;%path%" command.
- Switch to the Cefdir/libcef_dll directory and execute "CMake." command to generate VS 2013 project files and solution files
- Use vs 2013 to open the Project.sln in the Cefdir/libcef_dll directory, check libcef_dll_wrapper this project, open the project properties, set the C + + add-in directory, add the Cefdir directory
- Select Libcef_dll_wrapper, right mouse button, properties –> configuration Properties –>c/c++–> preprocessor definition, edit, add a Nominmax macro. This is to resolve the Min/max macro conflicts defined by Std::min/std::max and VC globally. Some cc files in Libcef_dll use the Std::min/max template function, do not add Nominmax, C2589 and C2059 errors may occur
- Debug version, runtime select "Multithreaded Debugging (MTd)"; release version select Mt.
- Compiling, generating libcef_dll_wrapper.lib files
- Put the Libcef_dll_wrapper.lib in the Cefdir/release (or debug) directory
I encountered some errors in compiling and found the solution, which is already included in the above steps.
Compiling the Cefsimple sample
With the Libcef_dll_wrapper, you can compile the cefsimple.
I originally wanted to use CMake generation, the results toss half a day, CMake executed, but did not generate the corresponding cefsimple.vcxproj ... Had to create a VS project manually.
The process is as follows:
- Create a Cefsimple project yourself, Win32 type, empty project
- Add cefsimple_win.cc,simple_app.cc,simple_handler.cc,simple_handler_win.cc as a source file to the project
- Add Resource.h,simple_app.h,simple_handler.h as a header file to the project
- Set up an additional inclusion directory and add the Cefdir directory
- Set up additional library directories, cefdir/release (or Debug)
- Add additional dependencies, adding Libcef_dll_wrapper.lib, Libcef.lib, DbgHelp.lib
- simple_app.cc in www.google.com replaced with www.baidu.com (Google can't open Ah ...) )
- Debug version, runtime select "Multithreaded Debugging (MTd)"; release version select Mt. Note that the choice here, and libcef_dll to be consistent, or will be out of link error
- Set the working directory to cefdir/release (or debug)
- Compile run
The runtime may crash and copy the contents of the Cefdir/resources directory to cef/release (or debug). CEF needs icudtl.dat, language files and so on.
Operating effects such as:
Cefdir Directory has a README.txt file, be sure to see, I compiled through after running the total crash, in the VS 1.1 point debug, see the program output, took a long time to find the resources of the problem!
OK, the environment is so good, then you can study the CEF SDK.
CEF Windows Development Environment Setup