11

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.

Soumya Kanti Sar
  • 145
  • 1
  • 1
  • 14
  • 1
    For beginner level C++ it will propably be better to use Qt/QML which has a [WebEngine control](https://doc.qt.io/qt-5/qtwebengine-index.html) that is based on Chromium like CEF. So you basically get the same features as with CEF but in a "batteries included" package. They have a [minimal example](https://doc.qt.io/qt-5/qtwebengine-webengine-minimal-example.html) which looks really straightforward. – zett42 Jun 30 '17 at 15:17
  • 2
    I have seen QT, but i don't want to use it since this will be a commercial project, and i am not willing to spend money on QT – Soumya Kanti Sar Jun 30 '17 at 15:41
  • 2
    @SoumyaKantiSar: You can use Qt in a commercial project also with dynamic linking. See here: https://www.qt.io/licensing-comparison/. You just need to confirm that your required feature doesn't specifically fall under commercially available list. – Azeem Jun 30 '17 at 16:40
  • BTW, it's similar with CEF, which is BSD-licensed but you also have to consider **all** licenses of the components of Chromium which it is based on. Type `chrome://credits` in Google Chrome to get an idea. You need a lawyer to verify that all of these can be used in a specific commercial scenario. – zett42 Jun 30 '17 at 16:47
  • @Azeem To be honest, i have not seen the dynamic linking thing of QT, and since i am new to C++, I don't even know what dynamic linking is. But it seems promising. – Soumya Kanti Sar Jun 30 '17 at 17:39
  • But i would really like to learn to implement chrome as well. In case i cannot use QT due to legal reasons. – Soumya Kanti Sar Jun 30 '17 at 17:43
  • @SoumyaKantiSar: You can watch this video on Qt official website to have a better understanding of these things. There's a lot of material online for this. – Azeem Jul 01 '17 at 03:06
  • @Azeem, No videos linked..... – Soumya Kanti Sar Jul 01 '17 at 03:16
  • @SoumyaKantiSar: Here it is: https://www.qt.io/qt-licensing-terms/ – Azeem Jul 01 '17 at 03:16
  • @Azeem, I think this (https://stackoverflow.com/questions/10130143/gpl-lgpl-and-static-linking) answers it all ? – Soumya Kanti Sar Jul 01 '17 at 05:22
  • @SoumyaKantiSar: Yes. This "dynamically linked: LGPL code stays LGPL, you can keep the proprietary code proprietary" will work for you. – Azeem Jul 01 '17 at 05:27
  • @Azeem , but here in this link (https://www.qt.io/faq/#_Toc_3_8) it's stated that "A few modules in Qt, however, use code from the WebKit project licensed under LGPLv2.1. These modules are Qt Script, Qt WebKit and Qt WebEngine" I think that this will get me in trouble, cause i will be using QT Webkit. – Soumya Kanti Sar Jul 01 '17 at 05:58
  • @SoumyaKantiSar: That's why I said earlier that you've to check first if the module list caters your needs. – Azeem Jul 01 '17 at 05:59
  • @Azeem i think it's still usable under the LGPL v2.1 sections 5 and 6, correct me if i am wrong. – Soumya Kanti Sar Jul 01 '17 at 06:43

1 Answers1

10

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: https://cef-builds.spotifycdn.com/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 100+ 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.

Dave S
  • 1,427
  • 1
  • 16
  • 18
  • Correct me if i am wrong, but i think that the .dll files are provided with the binary distributions, so why do i need an additional .lib, I want the most minimal and simple integration possible. And i did not understood your this line "Follow the existing logic to separate out the OS-specific parts". Since i'm a newbie to linking libraries, please pardon me, but i don't understand dynamic and static linking, neither do i understand how to link. – Soumya Kanti Sar Jul 01 '17 at 03:12
  • Even for DLLs the LIB file is needed to load the DLL and link to its functions. See edits above. – Dave S Jul 01 '17 at 03:52
  • The readme or a FAQ link shows how to make a Visual Studio project for CEFClient / Simple so you can build them again from source and try modifying them in place. – Dave S Jul 01 '17 at 03:58
  • 1
    For anyone finding this topic and looking for the binary distribution files, they have moved to this URL: https://www.spotify.com/us/opensource/ – GSP Jun 30 '22 at 13:08
  • 1
    Use https://cef-builds.spotifycdn.com/index.html as there are all current CEF builds, not just the ones spotify uses. – amaitland Jun 30 '22 at 20:48