You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Windows下不使用Visual Studio编译CEF生成.exe文件

Compiling CEF Binaries & Building .exe from Source on Windows (No Visual Studio)

Got it, let’s walk through how to get this done using MinGW or command-line tools—no Visual Studio required. I’ve broken this into two main parts: compiling the CEF binaries themselves, and building your own .exe from CEF source code.

Prerequisites First

Before diving in, make sure you have these tools installed:

  • MinGW-w64: Grab a recent version (x86_64 architecture recommended) with support for C++17 or later.
  • CMake: Needed to generate build files for MinGW/Ninja.
  • Ninja (optional but recommended): Faster than MinGW Makefiles for large projects like CEF.
  • Python 3: CEF’s build scripts rely on Python to handle dependencies and configuration.

Part 1: Compile CEF Binaries with MinGW

  1. Extract your CEF source package to a directory (e.g., C:\cef_source). Avoid spaces in the path—they can cause build errors.
  2. Open the MinGW-w64 Prompt (or a terminal where MinGW is in your PATH) and navigate to the CEF source directory.
  3. Create a build folder to keep source and build files separate:
    mkdir build && cd build
    
  4. Run CMake to generate MinGW-compatible build files. If your CEF dependencies are in a separate location, add -DCEF_ROOT_DIR=path/to/cef/deps to the command:
    cmake -G "MinGW Makefiles" .. -DCEF_ENABLE_SANDBOX=OFF
    
    Note: Disabling the sandbox (CEF_ENABLE_SANDBOX=OFF) is often necessary for MinGW builds, as Chromium’s sandbox has limited support with MinGW.
  5. Start the compilation. Use -j followed by your CPU core count to speed things up (e.g., -j4 for 4 cores):
    mingw32-make -j4
    
  6. Once done, your compiled binaries will be in the build/Release or build/Debug folder, depending on your CMake configuration.

Part 2: Build Your Own .exe from CEF Source

If you want to create a custom CEF-based application (not just compile the core binaries), here’s how:

  1. Write your CEF application code (e.g., main.cpp). You can use CEF’s cefclient example as a starting point—it’s included in the CEF source package.
  2. Create a CMakeLists.txt file to link your code with CEF. Here’s a minimal example:
    cmake_minimum_required(VERSION 3.10)
    project(MyCEFApp)
    
    # Point to your CEF source directory
    set(CEF_ROOT_DIR "C:/cef_source")
    include(${CEF_ROOT_DIR}/cmake/cef_variables.cmake)
    
    # Add your executable and link CEF libraries
    add_executable(MyCEFApp main.cpp)
    target_link_libraries(MyCEFApp ${CEF_STATIC_LIBRARIES})
    target_include_directories(MyCEFApp PRIVATE ${CEF_INCLUDE_DIRS})
    
  3. Repeat the build steps from Part 1: create a build folder, run CMake with MinGW Makefiles, then compile with mingw32-make. Your custom .exe will appear in the build directory.

Using Command-Line with Ninja (Alternative to MinGW Makefiles)

If you prefer Ninja for faster builds:

  1. When running CMake, use the Ninja generator instead:
    cmake -G Ninja .. -DCEF_ENABLE_SANDBOX=OFF
    
  2. Compile with:
    ninja
    

Quick Notes

  • CEF builds are resource-heavy—expect the first compile to take a while (30+ minutes depending on your hardware).
  • If you run into linker errors, double-check that MinGW’s architecture matches your CEF source (x86_64 vs x86).
  • Some advanced CEF features (like GPU acceleration) might have limited support with MinGW—test thoroughly if your app relies on these.

内容的提问来源于stack exchange,提问作者a verma

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 10:08:50