How to embed Chromium Embedded Framework in C++

Soumya Kanti Sar picture Soumya Kanti Sar · Jun 30, 2017 · Viewed 16k times · Source

I was creating a audio software project in Visual Studio. I want to make it cross platform so i was not using winforms, rather i started empty project.

But i wanted to use HTML/CSS/JS for the frontend part, for which i looked up on the internet and found Sciter. It was simple and easy to use but it was not up to the marks, as i wanted to use many html features which was not available. So i decided to use chromium embedded framework.

But since i am new to C++ programming, and especially visual studio, i am unable to figure out which files do i need to import to my project to make it work. At first i was trying to go with the source code, so that would make it cross platform. But i figured out it's quite hard to compile the source code, so i decided to use the .dll files instead. And so i downloaded the standard windows x64 distribution of CEF.

But i am literally confused on how to include that in my project. I have seen online videos, but they are meant for C# and i am using C++. I have also seen .Net version's tutorials, but since i am not using any .net controls or winforms library, I am literally confused on how to produce a GUI using it, and interface with the javascript.

All i want is a kisok instance of CEF where i will load html/css/js using c++ (by passing string values to c++ functions or the chrome API). I am going to use Vue.js library to make this easier on the javascript part. And some way to put in and get out data between the javascipt and c++

I tried to use CEFSharp, but i failed miserably and switched back. Now i am stuck with the libcef.dll and other such files, and i am unable to understand what to do. I am having trouble adding the include files to my project. I cannot find a way to reference the .dll file and all those stuff. I have no experience with importing third party libraries in c++.

Please suggest me a a resource or some tutorial that addresses my problem. (Please no winforms or .net controls, i want to do everything using native c++ code, as later i want to port it to linux and mac)

Also please do suggest me some way so that i could make this CEF induced code base portable to linux and mac as well.

Thanks.

Answer

Dave S picture Dave S · Jun 30, 2017

The Chromium Embedded Framework has a forum run by its developer here: http://www.magpcss.org/ceforum/index.php . See the FAQ in the Support subforum.

There are binary distributions available for Windows, OS X, and linux. They are currently hosted by Spotify here: http://opensource.spotify.com/cefbuilds/index.html

The supplied CEF3 files are native C++ not .Net. There is a CEFSharp project that wraps CEF3 for .Net but it is for C#.

What most people do to get started is work with the CEFSimple or (more fully featured) CEFClient sample applications that are included. These applications as written are compatible with the different OSes. These are supplied as source code for use with the already-compiled Chromium + CEF3 DLLs.

For example you start a new Visual Studio project and copy in the CEFSimple files, and link to the .lib for the CEF3 DLL. Follow the existing logic to separate out the OS-specific parts.

In Windows for native C++ the linker uses .lib files while building your EXE (see Linking : .a, .lib and .def files):

Linker - Input   (edit paths to match where you copied the binary files)
..\..\cef_binary_3\Release\libcef.lib
..\..\cef_binary_3\build\libcef_dll_wrapper\Release\libcef_dll_wrapper.lib

For distributing your application you include your EXE, the DLLs, the .PAK files and the 2 _blob.bin files. All of the files from the sample binary versions of CEFClient except the same .EXE. Yes, the zipped size really is 50+ MB! That's because unlike Microsoft's IE web control no part of the browser is included in the operating system.

Search the CEF forums for tips on running full-screen mode. For Windows this means changing the window style bits WS_ and WS_EX at the time the main browser window is created.