libcef Tutorial

远程工具向日葵的安装 linux安装向日葵系统 阅读详情
  Tutorial  
Tutorial explaining how to create a simple application using CEF3.
Updated  Aug 13, 2014 by  magreenb...@gmail.com

Introduction

This tutorial explains how to create a simple application using CEF3. It references the cefsimple example project which is included with trunkrevision 1535 and newer. For complete CEF3 usage information visit the GeneralUsage Wiki page.

Getting Started

Begin by downloading a binary distribution for your platform from http://cefbuilds.com. For the purposes of this tutorial download the 1750 branch or newer. Currently supported platforms include Windows, Linux and Mac OS X. Each binary distribution contains all files necessary to build a particular version of CEF3 on a particular platform. See the included README.txt file or the Getting Started section of the GeneralUsage Wiki page for a detailed description of binary distribution contents.

Building the Included Project

Applications based on CEF binary distributions can be built using standard platform build tools. This includes Visual Studio on Windows, Xcode on Mac OS X and gcc/make on Linux. Each platform has a slightly different build process and requirements.

Windows

Follow these steps to build the cefsimple application on Windows:

  1. Open the solution file appropriate to your version of Visual Studio. For example, when using Visual Studio 2010 open the cefclient2010.sln solution file.
  2. If you downloaded a 64-bit build make sure to select the 64-bit platform in Configuration Manager.
  3. Build the “cefsimple” target.
  4. If the build is successful an “out/Debug” directory (or “Release” if you selected the release configuration) will be created.
  5. Run “out/Debug/cefsimple.exe” to verify that it works.
Linux

Follow these steps to build the cefsimple application on Linux:

  1. Make sure you’re using one of the supported Linux distributions. This currently includes Debian Wheezy, Ubuntu Precise, and related Linux distributions. Newer versions will likely also work but may not have been tested.
  2. Install the required dependencies. This includes the build-essential, libgtk2.0-dev and libgtkglext1-dev packages (note that libgtkglext1-dev is only required for the cefclient example).
  3. Build the “cefsimple” target by running “./build.sh Debug”.
  4. If the build is successful an “out/Debug” directory (or “Release” if you selected the release configuration) will be created.
  5. Run “./out/Debug/cefsimple” to verify that it works.
Mac OS X

Follow these steps to build the cefsimple application on OS X:

  1. Open cefclient.xcodeproj using Xcode 4.x (Xcode 5.x is not yet tested or supported).
  2. Build the “cefsimple” target.
  3. If the build is successful an “xcodebuild/Debug” directory (or “Release” if you selected the release configuration) will be created.
  4. Run “open out/Debug/cefsimple.app” to verify that it works.

Loading a Custom URL

The cefsimple application loads google.com by default but you can change it to load a custom URL instead. The easiest way to load a different URL is via the command-line.

# Load the local file “c:\example\example.html”
cefsimple.exe --url=file://c:/example/example.html

You can also edit the source code in cefsimple/simple_app.cpp and recompile the application to load your custom URL by default.

# Load the local file “c:\example\example.html”
…
  if (url.empty())
    url = "file://c:/example/example.html";
…

Application Components

All CEF applications have the following primary components:

  1. The CEF dynamic library (libcef.dll on Windows, libcef.so on Linux, “Chromium Embedded Framework.framework” on OS X).
  2. Support libraries (ICU for unicode, ffmpeg for media playback, etc).
  3. Resources (html/js/css for built-in features, strings, etc).
  4. Client executable (cefsimple in this example).

The CEF dynamic library, support libraries and resources will be the same for every CEF-based application. They are included in the Debug/Release or Resources directory of the binary distribution. See the README.txt file included in the binary distribution for details on which of these files are required and which can be safely left out. See below for a detailed description of the required application layout on each platform.

Architecture in 60 Seconds

The below list summarizes the items of primary importance for this tutorial:

  • CEF uses multiple processes. The main application process is called the “browser” process. Sub-processes will be created for renderers, plugins, GPU, etc.
  • On Windows and Linux the same executable can be used for the main process and sub-processes. On OS X you are required to create a separate executable and app bundle for sub-processes.
  • Most processes in CEF have multiple threads. CEF provides functions and interfaces for posting tasks between these various threads.
  • Some callbacks and functions may only be used in particular processes or on particular threads. Make sure you read the source code comments in the API headers before you begin using a new callback or function for the first time.

Read the GeneralUsage Wiki page for complete discussion of the above points.

Source Code

The cefsimple application initializes CEF and creates a single popup browser window. The application terminates when all browser windows have been closed. Program flow is as follows:

  1. The OS executes the browser process entry point function (main or wWinMain).
  2. The entry point function:
    1. Creates an instance of SimpleApp which handles process-level callbacks.
    2. Initializes CEF and runs the CEF message loop.
  3. After initialization CEF calls SimpleApp::OnContextInitialized(). This method:
    1. Creates the singleton instance of SimpleHandler.
    2. Creates a browser window using CefBrowserHost::CreateBrowserSync().
  4. All browsers share the SimpleHandler instance which is responsible for customizing browser behavior and handling browser-related callbacks (life span, loading state, title display, etc).
  5. When a browser window is closed SimpleHandler::OnBeforeClose() is called. When all browser windows have closed the OnBeforeClose implementation quits the CEF message loop to exit the application.

Your binary distribution may include newer versions of the below files. However, the general concepts remain unchanged.

Entry Point Function

Execution begins in the browser process entry point function. This function is responsible for initializing CEF and any OS-related objects. For example, it initializes GTK on Linux and allocates the necessary Cocoa objects on OS X. OS X has a separate entry point function for helper processes (see the OS X section below).

Windows
#include <windows.h>

#include "cefsimple/simple_app.h"
#include "include/cef_sandbox_win.h"


// Set to 0 to disable sandbox support.
#define CEF_ENABLE_SANDBOX 1

#if CEF_ENABLE_SANDBOX
// The cef_sandbox.lib static library is currently built with VS2010. 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);

  void* sandbox_info = NULL;

#if CEF_ENABLE_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<SimpleApp> 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 !CEF_ENABLE_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;
}
Linux
// cefsimple_gtk.cpp
#include <gtk/gtk.h>

#include "cefsimple/simple_app.h"

// Entry point function for all processes.
int main(int argc, char* argv[]) {
  // Provide CEF with command-line arguments.
  CefMainArgs main_args(argc, argv);
  
  // SimpleApp implements application-level callbacks. It will create the first
  // browser instance in OnContextInitialized() after CEF has initialized.
  CefRefPtr<SimpleApp> 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(), NULL);
  if (exit_code >= 0) {
    // The sub-process has completed so return here.
    return exit_code;
  }

  // Initialize GTK.
  gtk_init(&argc, &argv);

  // Specify CEF global settings here.
  CefSettings settings;

  // Initialize CEF for the browser process.
  CefInitialize(main_args, settings, app.get(), NULL);

  // Run the CEF message loop. This will block until CefQuitMessageLoop() is
  // called.
  CefRunMessageLoop();

  // Shut down CEF.
  CefShutdown();

  return 0;
}
Mac OS X

Browser process entry point:

// cefsimple_mac.mm
#import <Cocoa/Cocoa.h>

#include "cefsimple/simple_app.h"
#include "cefsimple/simple_handler.h"
#include "cefsimple/util.h"
#include "include/cef_application_mac.h"

// Provide the CefAppProtocol implementation required by CEF.
@interface SimpleApplication : NSApplication<CefAppProtocol> {
@private
  BOOL handlingSendEvent_;
}
@end

@implementation SimpleApplication
- (BOOL)isHandlingSendEvent {
  return handlingSendEvent_;
}

- (void)setHandlingSendEvent:(BOOL)handlingSendEvent {
  handlingSendEvent_ = handlingSendEvent;
}

- (void)sendEvent:(NSEvent*)event {
  CefScopedSendingEvent sendingEventScoper;
  [super sendEvent:event];
}
@end


// Receives notifications from the application.
@interface SimpleAppDelegate : NSObject
- (void)createApp:(id)object;
@end

@implementation SimpleAppDelegate

// Create the application on the UI thread.
- (void)createApp:(id)object {
  [NSApplication sharedApplication];
  [NSBundle loadNibNamed:@"MainMenu" owner:NSApp];

  // Set the delegate for application events.
  [NSApp setDelegate:self];
}

// Called when the application's Quit menu item is selected.
- (NSApplicationTerminateReply)applicationShouldTerminate:
      (NSApplication *)sender {
  // Request that all browser windows close.
  if (SimpleHandler* handler = SimpleHandler::GetInstance())
    handler->CloseAllBrowsers(false);

  // Cancel the termination. The application will exit after all windows have
  // closed.
  return NSTerminateCancel;
}

// Sent immediately before the application terminates. This signal should not
// be called because we cancel the termination.
- (void)applicationWillTerminate:(NSNotification *)aNotification {
  ASSERT(false);  // Not reached.
}

@end


// Entry point function for the browser process.
int main(int argc, char* argv[]) {
  // Provide CEF with command-line arguments.
  CefMainArgs main_args(argc, argv);

  // SimpleApp implements application-level callbacks. It will create the first
  // browser instance in OnContextInitialized() after CEF has initialized.
  CefRefPtr<SimpleApp> app(new SimpleApp);

  // Initialize the AutoRelease pool.
  NSAutoreleasePool* autopool = [[NSAutoreleasePool alloc] init];

  // Initialize the SimpleApplication instance.
  [SimpleApplication sharedApplication];

  // Specify CEF global settings here.
  CefSettings settings;

  // Initialize CEF for the browser process.
  CefInitialize(main_args, settings, app.get(), NULL);
  
  // Create the application delegate.
  NSObject* delegate = [[SimpleAppDelegate alloc] init];
  [delegate performSelectorOnMainThread:@selector(createApp:) withObject:nil
                          waitUntilDone:NO];

  // Run the CEF message loop. This will block until CefQuitMessageLoop() is
  // called.
  CefRunMessageLoop();

  // Shut down CEF.
  CefShutdown();

  // Release the delegate.
  [delegate release];

  // Release the AutoRelease pool.
  [autopool release];

  return 0;
}

Sub-process entry point:

// process_helper_mac.cpp
#include "include/cef_app.h"

// Entry point function for sub-processes.
int main(int argc, char* argv[]) {
  // Provide CEF with command-line arguments.
  CefMainArgs main_args(argc, argv);

  // Execute the sub-process.
  return CefExecuteProcess(main_args, NULL, NULL);
}

SimpleApp

SimpleApp is responsible for handling process-level callbacks. It exposes some interfaces/methods that are shared by multiple processes and some that are only called in a particular process. The CefBrowserProcessHandler interface, for example, is only called in the browser process. There’s a separate CefRenderProcessHandler interface (not shown in this example) that is only called in the render process. Note that GetBrowserProcessHandler() must return |this| because SimpleApp implements both CefApp and CefBrowserProcessHandler. See theGeneralUsage Wiki page or API header files for additional information on CefApp and related interfaces.

// simple_app.h
#include "include/cef_app.h"

class SimpleApp : public CefApp,
                  public CefBrowserProcessHandler {
 public:
  SimpleApp();

  // CefApp methods:
  virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler()
      OVERRIDE { return this; }

  // CefBrowserProcessHandler methods:
  virtual void OnContextInitialized() OVERRIDE;

 private:
  // Include the default reference counting implementation.
  IMPLEMENT_REFCOUNTING(SimpleApp);
};


// simple_app.cpp
#include "cefsimple/simple_app.h"

#include <string>

#include "cefsimple/simple_handler.h"
#include "cefsimple/util.h"
#include "include/cef_browser.h"
#include "include/cef_command_line.h"

SimpleApp::SimpleApp() {
}

void SimpleApp::OnContextInitialized() {
  REQUIRE_UI_THREAD();

  // Information used when creating the native window.
  CefWindowInfo window_info;

#if defined(OS_WIN)
  // On Windows we need to specify certain flags that will be passed to
  // CreateWindowEx().
  window_info.SetAsPopup(NULL, "cefsimple");
#endif

  // SimpleHandler implements browser-level callbacks.
  CefRefPtr<SimpleHandler> handler(new SimpleHandler());

  // Specify CEF browser settings here.
  CefBrowserSettings browser_settings;

  std::string url;

  // Check if a "--url=" value was provided via the command-line. If so, use
  // that instead of the default URL.
  CefRefPtr<CefCommandLine> command_line =
      CefCommandLine::GetGlobalCommandLine();
  url = command_line->GetSwitchValue("url");
  if (url.empty())
    url = "http://www.google.com";

  // Create the first browser window.
  CefBrowserHost::CreateBrowserSync(window_info, handler.get(), url,
                                    browser_settings, NULL);
}

SimpleHandler

SimpleHandler is responsible for handling browser-level callbacks. These callbacks are executed in the browser process. In this example we use the same CefClient instance for all browsers, but your application can use different CefClient instances as appropriate. See the GeneralUsageWiki page or API header files for additional information on CefClient and related interfaces.

// simple_handler.h
#include "include/cef_client.h"

#include <list>

class SimpleHandler : public CefClient,
                      public CefDisplayHandler,
                      public CefLifeSpanHandler,
                      public CefLoadHandler {
 public:
  SimpleHandler();
  ~SimpleHandler();

  // Provide access to the single global instance of this object.
  static SimpleHandler* GetInstance();

  // CefClient methods:
  virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE {
    return this;
  }
  virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE {
    return this;
  }
  virtual CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE {
    return this;
  }

  // CefDisplayHandler methods:
  virtual void OnTitleChange(CefRefPtr<CefBrowser> browser,
                             const CefString& title) OVERRIDE;

  // CefLifeSpanHandler methods:
  virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
  virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;

  // CefLoadHandler methods:
  virtual void OnLoadError(CefRefPtr<CefBrowser> browser,
                           CefRefPtr<CefFrame> frame,
                           ErrorCode errorCode,
                           const CefString& errorText,
                           const CefString& failedUrl) OVERRIDE;

  // Request that all existing browser windows close.
  void CloseAllBrowsers(bool force_close);

 private:
  // List of existing browser windows. Only accessed on the CEF UI thread.
  typedef std::list<CefRefPtr<CefBrowser> > BrowserList;
  BrowserList browser_list_;

  // Include the default reference counting implementation.
  IMPLEMENT_REFCOUNTING(SimpleHandler);
};


// simple_handler.cpp
#include "cefsimple/simple_handler.h"

#include <sstream>
#include <string>

#include "cefsimple/util.h"
#include "include/cef_app.h"
#include "include/cef_runnable.h"

namespace {

SimpleHandler* g_instance = NULL;

}  // namespace

SimpleHandler::SimpleHandler() {
  ASSERT(!g_instance);
  g_instance = this;
}

SimpleHandler::~SimpleHandler() {
  g_instance = NULL;
}

// static
SimpleHandler* SimpleHandler::GetInstance() {
  return g_instance;
}

void SimpleHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
  REQUIRE_UI_THREAD();

  // Add to the list of existing browsers.
  browser_list_.push_back(browser);
}

void SimpleHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
  REQUIRE_UI_THREAD();

  // Remove from the list of existing browsers.
  BrowserList::iterator bit = browser_list_.begin();
  for (; bit != browser_list_.end(); ++bit) {
    if ((*bit)->IsSame(browser)) {
      browser_list_.erase(bit);
      break;
    }
  }

  if (browser_list_.empty()) {
    // All browser windows have closed. Quit the application message loop.
    CefQuitMessageLoop();
  }
}

void SimpleHandler::OnLoadError(CefRefPtr<CefBrowser> browser,
                                CefRefPtr<CefFrame> frame,
                                ErrorCode errorCode,
                                const CefString& errorText,
                                const CefString& failedUrl) {
  REQUIRE_UI_THREAD();

  // Don't display an error for downloaded files.
  if (errorCode == ERR_ABORTED)
    return;

  // Display a load error message.
  std::stringstream ss;
  ss << "<html><body bgcolor=\"white\">"
        "<h2>Failed to load URL " << std::string(failedUrl) <<
        " with error " << std::string(errorText) << " (" << errorCode <<
        ").</h2></body></html>";
  frame->LoadString(ss.str(), failedUrl);
}

void SimpleHandler::CloseAllBrowsers(bool force_close) {
  if (!CefCurrentlyOn(TID_UI)) {
    // Execute on the UI thread.
    CefPostTask(TID_UI,
        NewCefRunnableMethod(this, &SimpleHandler::CloseAllBrowsers,
                             force_close));
    return;
  }

  if (browser_list_.empty())
    return;

  BrowserList::const_iterator it = browser_list_.begin();
  for (; it != browser_list_.end(); ++it)
    (*it)->GetHost()->CloseBrowser(force_close);
}


// simple_handler_win.cpp -- Windows-specific code.
#include "cefsimple/simple_handler.h"

#include <string>
#include <windows.h>

#include "cefsimple/util.h"
#include "include/cef_browser.h"

void SimpleHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
                                  const CefString& title) {
  REQUIRE_UI_THREAD();

  CefWindowHandle hwnd = browser->GetHost()->GetWindowHandle();
  SetWindowText(hwnd, std::wstring(title).c_str());
}


// simple_handler_gtk.cc  -- Linux-specific code.
#include "cefsimple/simple_handler.h"

#include <gtk/gtk.h>
#include <string>

#include "cefsimple/util.h"
#include "include/cef_browser.h"

void SimpleHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
                                  const CefString& title) {
  REQUIRE_UI_THREAD();

  GtkWidget* window = gtk_widget_get_ancestor(
      GTK_WIDGET(browser->GetHost()->GetWindowHandle()),
      GTK_TYPE_WINDOW);
  std::string titleStr(title);
  gtk_window_set_title(GTK_WINDOW(window), titleStr.c_str());
}


// simple_handler_mac.mm -- OS X-specific code.
#include "cefsimple/simple_handler.h"

#import <Cocoa/Cocoa.h>

#include "cefsimple/util.h"
#include "include/cef_browser.h"

void SimpleHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
                                  const CefString& title) {
  REQUIRE_UI_THREAD();

  NSView* view = (NSView*)browser->GetHost()->GetWindowHandle();
  NSWindow* window = [view window];
  std::string titleStr(title);
  NSString* str = [NSString stringWithUTF8String:titleStr.c_str()];
  [window setTitle:str];
}

Build Steps

Build steps vary depending on the platform. Explore the project files included with the binary distribution for a complete understanding of all required steps. The build steps common to all platforms can generally be summarized as follows:

  1. Compile the libcef_dll_wrapper static library.
  2. Compile the application source code files. Link against the libcef dynamic library and the libcef_dll_wrapper static library.
  3. Copy libraries and resources to the output directory.

Windows

  1. Compile the libcef_dll_wrapper static library.
  2. Compile/link cefsimple.exe.
    1. Required source code files include: cefsimple_win.cpp, simple_app.cpp, simple_handler.cpp, simple_handler_win.cpp.
    2. Required link libraries include: comctl32.lib, shlwapi.lib, rcprt4.lib, libcef_dll_wrapper.lib, libcef.lib, cef_sandbox.lib. Note that cef_sandbox.lib (required for sandbox support) is a static library currently built with Visual Studio 2010 and it may not compile with other Visual Studio versions. You can disable sandbox support by setting CEF_ENABLE_SANDBOX to 0 in cefsimple_win.cpp.
    3. Resource file is cefsimple.rc.
    4. Manifest files are cefsimple.exe.manifest and compatibility.manifest.
  3. Copy all files from the Resources directory to the output directory.
  4. Copy all files from the Debug/Release directory to the output directory.

The resulting directory structure looks like this:

Application/
  cefsimple.exe  <= cefsimple application executable
  libcef.dll <= main CEF library
  icudt.dll <= ICU unicode support library
  ffmpegsumo.dll <= HTML5 audio/video support library
  libEGL.dll, libGLESv2.dll, … <= accelerated compositing support libraries
  cef.pak, devtools_resources.pak <= non-localized resources and strings
  locales/
    en-US.pak, … <= locale-specific resources and strings

Linux

  1. Compile the libcef_dll_wrapper static library.
  2. Compile/link cefsimple.
    1. Required source code files include: cefsimple_gtk.cpp, simple_app.cpp, simple_handler.cpp, simple_handler_gtk.cpp.
    2. Required link libraries include: libcef_dll_wrapper.so, libcef.so and dependencies (identified at build time using the “pkg-config” tool).
    3. Configure the rpath to find libcef.so in the current directory (“-Wl,-rpath,.”) or use the LD_LIBRARY_PATH environment variable.
  3. Copy all files from the Resources directory to the output directory.
  4. Copy all files from the Debug/Release directory to the output directory.
  5. Set SUID permissions on the chrome-sandbox executable to support the sandbox. This is done as the last step in the provided build.sh script.

The resulting directory structure looks like this:

Application/
  cefsimple  <= cefsimple application executable
  chrome-sandbox <= sandbox support binary
  libcef.so <= main CEF library
  ffmpegsumo.so <-- HTML5 audio/video support library
  cef.pak, devtools_resources.pak <= non-localized resources and strings
  locales/
    en-US.pak, … <= locale-specific resources and strings

Mac OS X

  1. Compile the libcef_dll_wrapper static library.
  2. Compile/link/package the “cefsimple Helper” app.
    1. Required source code files include: process_helper_mac.cpp.
    2. Required link frameworks include: AppKit.framework, Chromium Embedded Framework.framework (unversioned, included in the binary distribution).
    3. App bundle configuration is provided via “cefsimple/mac/helper-Info.plist”.
    4. Use “install_name_tool -change” to rewrite the framework link so that it points to the “Chromium Embedded Framework.framework/Chromium Embedded Framework” library in the correct location.
  3. Compile/link/package the “cefsimple” app.
    1. Required source code files include: cefsimple_mac.mm, simple_app.cpp, simple_handler.cpp, simple_handler_mac.mm.
    2. Required link frameworks include: AppKit.framework, Chromium Embedded Framework.framework (unversioned, included in the binary distribution).
    3. App bundle configuration is provided via “cefsimple/mac/Info.plist”.
    4. Use “install_name_tool -change” to rewrite the framework link so that it points to the “Chromium Embedded Framework.framework/Chromium Embedded Framework” library in the correct location.
  4. Create a Contents/Frameworks directory in the cefsimple.app bundle. Copy the following files to that directory: libplugin_carbon_interpose.dylib, “cefsimple Helper.app”, “Chromium Embedded Framework.framework”.
  5. Run the “tools/make_more_helpers.sh” script to copy/configure the sub-process helper app bundles based on “cefsimple Helper.app”.

The resulting directory structure looks like this:

cefsimple.app/
  Contents/
    Frameworks/
      Chromium Embedded Framework.framework/
        Chromium Embedded Framework <= main application library
        Libraries/
          ffmpegsumo.so <= HTML5 audio/video support library
        Resources/
          cef.pak, devtools_resources.pak <= non-localized resources and strings
          crash_inspector, crash_report_sender <= breakpad support
          en.lproj/, ... <= locale-specific resources and strings
          Info.plist
      libplugin_carbon_interpose.dylib <= plugin support library
      cefsimple Helper.app/
        Contents/
          Info.plist
          MacOS/
            cefsimple Helper <= helper executable
          Pkginfo
      cefsimple Helper EH.app/
        Contents/
          Info.plist
          MacOS/
            cefsimple Helper EH <= helper executable
          Pkginfo
      cefsimple Helper NP.app/
        Contents/
          Info.plist
          MacOS/
            cefsimple Helper NP <= helper executable
          Pkginfo
      Info.plist
    MacOS/
      cefsimple <= cefsimple application executable
    Pkginfo
    Resources/
      cefsimple.icns, ... <= cefsimple application resources
linux CEF 离屏渲染详解 Linux CEF 离屏渲染详解 1.下载linux版本的cef源码 下载地址:https://cef-builds.spotifycdn.com/index.html 下载对应的源码  tar -xjvf 文件名.tar.bz2 // 解压到当前文件夹 2. 编译cef 1、自行安装cmake make gcc g++ gdb等 工具 2、首先 cmake 编译 cef文件夹内的CMakeLists.txt 文件生成 MakeFile 文件 3、再用 阅读详情

相关推荐

Ubuntu20.04 libcef笔记

零、 网站:CEF Automated Builds 下载:cef_binary_94.4.11+gc4d96f0+chromium-94.0.4606.81_linux64.tar.bz2 壹、 开始搞之前先看下CMakeLists.txt、LICENSE.txt、README.txt,尤其是CMakeLists.txt,这个文件写了工程如何生成。 贰、 安装:libgtk3.0-dev、libgtkglext1-dev、libx11-dev,缺啥补啥。 sudo ap...

DC的博客 916

【精品】centos/rocky_linux的Zoom安装问题解决方案

【精品】centos/rocky_linux的Zoom安装问题解决方案

liurugongzi123的博客 618

Qt 内嵌简化版cef 只有15M,包含js C++互调,

Qt 内嵌简化版cef 只有15M,包含js C++互调,内部qt是用的静态编译,大家需要换成自已用的Qt环境。release可以直接运行exe

CEF General Usage(CEF3预览)

CEF General Usage(CEF3预览) 介绍 CEF全称Chromium Embedded Framework,是一个基于Google Chromium 的开源项目。Google Chromium项目主要是为Google Chrome应用开发的,而CEF的目标则是为第三方应用提供可嵌入浏览器支持。CEF隔离底层Chromium和Blink的复杂代码,并提供一套产品级稳定的API,发...

weixin_33948416的博客 532

cefgui:使用 Chromium 嵌入式框架 (CEF) 的 OpenGL GUI

头孢吉 注意:这个项目最初的目的是将 GUI 代码与我正在开发的游戏分离,但由于和其他一些在工作时变得明显的原因,最终选择与游戏引擎更紧密地集成。 这是我目前使用 CEF 的一个非常早期的版本,所以使用风险自负! 使用 Chromium 嵌入式框架 (CEF) 的 OpenGL GUI 实现。 去做 更好地处理调整窗口大小 将鼠标和键盘事件发送到浏览器 实现javascript回调 笔记 libcef.so 超出了 Github 的文件大小限制,因此未包含在 repo 中。 当前使用 OpenGL 3.3 版为 Arch Linux 制作的示例 写使用说明 添加 cegui_path 设置而不是使用硬编码路径 执照

[SoC]SoC验证中bootcode与firmware相关验证经验总结

本文总结了SoC验证中bootcode和firmware的验证经验。重点介绍了两种数据加载方法:1)使用Verilog系统函数$readmemh/$readmemb直接写入ROM/ARAM,需注意文件路径、格式和斜杠方向;2)通过Memory Hierarchy在initial块中操作,需要添加适当延时并注意路径拼接。文章还提供了在testcase phase中先读取数据到HASH再写入SRAM的示例,并强调加载后需使能edc_bypass以避免ECC错误。验证过程中需特别注意文件位置、格式要求及路径处理等

元直的博客 2497

libcef 相关资料记录

libcef 最新代码。

niuxuexin的专栏 803

Android AVB 分析(十三)dm-verity 设备是如何映射的?

在上一篇《Android AVB 分析(十二)嵌入式设备安全中的 dm-verity 简介》介绍 dm-verity 原理的时候,作者提供了一个 dm-verity 演示的例子。本篇我们基于 AOSP 源码 `android-13.0.0_r41` 实际编译生成的 Google Pixel 7 (“panther”) 设备的 system 分区镜像进行 dm-verity 设备验证实战。

洛奇看世界 2438

Linux WallpaperEngine项目中的libcef.so依赖问题解析

在Linux平台上使用WallpaperEngine时,部分用户可能会遇到一个常见的依赖问题——系统提示无法加载libcef.so共享库文件。这个问题通常发生在通过AUR(Arch User Repository)安装软件包后首次运行时。 ## 问题本质 libcef.so是Chromium Embedded Framework(CEF)的核心库文件,WallpaperEngine的部分功能依...

gitblog_07154的博客 594

老款 NUC 复活计划:装 Ubuntu 部署 OpenClaw 本地 AI

老款 NUC 变身本地 AI 服务器指南 本文详细介绍了如何将老旧华硕 NUC 设备改造为本地 AI 服务器。主要内容包括: 硬件评估:列出老款 NUC 的最低配置要求(i3 6代/8GB内存/256GB SSD),并提供兼容性检查命令和性能预期表 系统准备:指导备份数据、下载 Ubuntu 22.04 LTS 和制作启动盘的方法(Windows/Linux双平台) 安装流程:从 BIOS 设置到 Ubuntu 安装的完整步骤,包括推荐的分区方案 系统优化:禁用不必要的服务、内核参数调优、Swap 配置和

博客 7607

"error while loading shared libraries: xxx.so.x" 错误的原因和解决办法

今天执行caffe例子mnist时,报错如下: error while loading shared libraries: libcaffe.so.1.0.0-rc3: cannot open shared object file: No such file or directory 错误的原因: 找不到lib这个文件。 原因一般有两个, 一个是操作系统里确实没有包含该共享库(lib.so...

641

YOLOv11魔改高效涨点 | 注意力篇 | SimAM注意力:基于神经科学的 3D 注意力机制,三维权重的暴力美学,无参数也能暴力涨点?代码极简,彻底疯狂!!!

在本文中,我们为卷积神经网络(ConvNets)提出了一个概念简单但非常有效的注意力模块。与现有的通道注意力(Channel-wise)和空间注意力(Spatial-wise)模块不同,我们的模块在不向原始网络添加参数的情况下,推断出层中特征图的 3D 注意力权重。具体来说,我们基于一些知名的神经科学理论,提出优化一个能量函数来寻找每个神经元的重要性。我们进一步推导出了该能量函数的快速闭式解,并表明该解可以用不到十行代码实现。

猫天意的博客 248

libcef-框架架构中概念介绍-命令行参数-元素布局-应用程序结构(二)

文章目录1.命令行参数2.应用布局2.1 windows2.2 linux2.3 MacOS3.应用结构3.1 入口函数3.2 单个可执行文件3.3 单独的子进程可执行文件4.作者答疑 1.命令行参数   CEF3 和 Chromium 中的许多功能可以使用命令行参数进行配置。这些参数采用“–some-argument[=optional-param]”的形式,并通过 CefExecuteProcess() 和 CefMainArgs 结构传递到 CEF(请参阅下面的“应用程序结构”部分)。   要在将 C

插件开发 1771

国科大学习资料--数据挖掘(刘莹)--第三章习题及参考答案

国科大学习资料–数据挖掘(刘莹)–第三章习题及参考答案 国科大学习资料–数据挖掘(刘莹)–第三章习题及参考答案 国科大学习资料–数据挖掘(刘莹)–第三章习题及参考答案 第 3 章分类与回归 3.1简述决策树分类的主要步骤。 答:决策树生成的过程如下: (1)对数据源进行数据预处理, 得到训练集和测试集; (2)对训练集进行训练; (3)对初始决策树进行树剪枝; (4)由所得到的决策树提取分类规则; (5)使用测试数据集进行预测,评估决策树模型; 3.2给定决策树,选项有:(1)将决策树转换成规则,然后对结果

无名何许人的博客 3090

基于STM32的智能鱼缸设计

为了缓解学习、生活、工作带来的压力,提升生活品质,许多人喜欢在家中、办公室等场所养鱼。为节省鱼友时间、劳力、增加养鱼乐趣;为此,本文基于STM32单片机设计了一款智能鱼缸。该鱼缸可以实现水温检测、水质检测、自动或手动换水、氛围灯灯光变换和自动或手动喂食等功能为一体的控制系统,可通过控制键进行一键控制。...

1万+

nim_duilib中对CEF的支持

CEF控件(CefControl)是nim_duilib对libcef(Chromium Embedded Framework)的封装,将Chromium浏览器功能集成到duilib界面库中。该控件支持HTML5渲染、JavaScript执行等现代网页功能,提供窗口模式和离屏渲染两种实现方式。使用时需下载对应版本的libcef二进制文件(32位/64位)放置到指定目录,并通过属性文件或手动配置工程属性进行集成。项目提供简单浏览器示例和多标签浏览器示例,支持最新版和109版CEF,需注意不同版本对操作系统的兼

m0_51545131的博客 761

PLC的模糊PID控制

模糊PID控制包括模糊化,确定模糊规则,解模糊等组成部分,小车通过传感器采集赛道信息,PLC通过温度传感器获取炉内温度,确定当前实际温度和设定目标值的偏差e(error), e=setpoint-input以及偏差的变化ec(当前偏差-上次偏差),根据给定的模糊规则进行模糊推理,最后对模糊参数进行解模糊,输出PID控制参数 其次我们需要对这2个参数进行模糊化,e 、 ec 这里我对e进行举例,两个输入的标准化范围都在 [-1,1] 范围内。模糊逻辑控制器还产生范围 [-1,1] 内的归一化输出。 博

RXXW_Dor的博客 1万+

CEF预览

CEF General Usage(CEF3预览) 介绍 CEF全称Chromium Embedded Framework,是一个基于Google Chromium 的开源项目。Google Chromium项目主要是为Google Chrome应用开发的,而CEF的目标则是为第三方应用提供可嵌入浏览器支持。CEF隔离底层Chromium和Blink的复杂代码,并提供一套产品级稳定的API,发布跟踪具体Chromium版本的分支,以及二进制包。CEF的大部分特性都提供了丰富的默认实现,让使用者做尽量少的定制

weixin_42252757的博客 1553

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

cannot allocate memory in static TLS block

glibc-2.22 中加入了如下commit:f8aeae347377f3dfa8cbadde057adf1827fb1d44。如果不是内存太小,那是不是因为glibc太旧呢?考虑 glibc 2.22 以后的版本。

eloudy的专栏 490

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

libcef(一)编译CEF

下载二进制原码 链接地址 不同系统可选择不同版本,因有需求故我选的是Win32版本(我的系统是Win10,64位)。 想要选择其他版本可点击上图中的Show All Builds字样之后再点击Show More Builds字样可出现更多版本。 我选择的是下图所示版本(当时下载的时候还是最新版本,等想起来截图做笔记已经更新了其他版本)。 关于CEF的版本 Standard Distribution:标准二进制分发。包括头文件,libcef_dll_wrapper源代码,二进制文件,CMake配置文

chen_ling_16的博客 8383

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

关于ARM-LINUX在启动时,遇到/sbin/init 找不到libc.so的原因

单位项目,用自制的交叉编译器,制作rootfs,在启动的时候遇到 运行/sbin/init中提示找不到libc.so.6。 查询原因,ld-linux-armhf.so.3中,指定了动态库的加载地址不为/lib与/usr/lib,而是在glibc编译时指定的安装地址(自制arm-linux-gnueabi-gcc)。 https://sourceware.org/glibc/wiki/Tes

qq_25771603的博客 1569
上一篇: C++ COM中IDispatch之Invoke获取对象时,注意点
下一篇: chromium之gyp构建系统
hellochenlian
博客等级 码龄17年 629粉丝 295原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值