Complete Guide to Compiling RustDesk Flutter Version on Windows

Complete Guide to Compiling RustDesk Flutter Version on Windows

📋 Introduction

This tutorial is suitable for compiling the Flutter version of RustDesk on Windows 10/11. RustDesk is an open-source remote desktop software, and the Flutter version provides a more modern UI interface.

Test Environment:

  • Windows 11
  • RustDesk version 1.43
  • Flutter 3.24.5
  • Rust 1.90+

🛠️ Part One: Installing Necessary Dependencies

1.1 Install Visual Studio (C++ Build Environment)

  1. Download Visual Studio Community 2022 [1]

  2. Select during installation:

  • Workload: Desktop development with C++

  • Individual Components: Ensure MSVC and Windows SDK are included

  • Restart the computer after installation is complete
  • 1.2 Install Rust Development Environment

    1. Download rustup-init.exe [2]

    2. Run rustup-init.exe as administrator

    3. Select the default installation option (press 1 and then Enter)
    4. After installation, close and reopen the terminal

    Verify installation:

    rustc --version
    cargo --version

    1.3 Install Git

    1. Download Git for Windows [3]

    2. Use default options during installation
    3. Restart the terminal after installation

    1.4 Install vcpkg (C++ Dependency Manager)

    Open Git Bash (not PowerShell), and run:

    # Navigate to the directory where you want to install vcpkg, e.g., D:\
    cd /d
    
    # Clone vcpkg
    git clone https://github.com/microsoft/vcpkg
    
    # Initialize vcpkg
    cd vcpkg
    ./bootstrap-vcpkg.bat
    
    # Install libraries required by RustDesk (this step may take a long time, especially for the aom library)
    ./vcpkg install libvpx:x64-windows-static libyuv:x64-windows-static opus:x64-windows-static aom:x64-windows-static

    Important: Add system environment variable

    • Right-click “This PC” → Properties → Advanced system settings → Environment Variables
    • Create a new in “System Variables”:

      • Variable Name: <span>VCPKG_ROOT</span>

      • Variable Value: <span>D:\vcpkg</span> (replace with your actual path)

    1.5 Install LLVM

    1. Download LLVM 15.0.2 (64-bit) [4]

    2. Install to <span>C:\Program Files\LLVM</span>

    3. Add system environment variable:

    • Variable Name: <span>LIBCLANG_PATH</span>

    • Variable Value: <span>C:\Program Files\LLVM\bin</span>

    1.6 Install Flutter SDK

    Method A: Using FVM (Recommended, can manage multiple versions)

    # Install FVM
    dart pub global activate fvm
    
    # Add Dart global package path to PATH
    # %USERPROFILE%\AppData\Local\Pub\Cache\bin

    Method B: Directly Install Flutter

    1. Download Flutter SDK [5], select 3.24.5 version

    2. Extract to <span>C:\flutter</span>

    3. Add to PATH: <span>C:\flutter\bin</span>

    Verify installation:

    flutter --version
    # Should display Flutter 3.24.5

    1.7 Install Python 3

    1. Download Python 3.11+ [6]

    2. Check the box for “Add Python to PATH”

    3. Verify: <span>python --version</span>

    🔧 Part Two: Preparing RustDesk Source Code

    2.1 Clone RustDesk Repository

    # Choose a working directory, e.g., D:\Projects
    cd D:\Projects
    
    # Clone the code (including submodules)
    git clone --recurse-submodules https://github.com/rustdesk/rustdesk
    cd rustdesk

    2.2 Enable Windows Developer Mode

    This is a necessary step; otherwise, you will encounter symlink errors.

    Method 1 (Recommended):

    start ms-settings:developers

    In the opened settings window, enable “Developer Mode”.

    Method 2:

    • Open “Settings” → “Update & Security” → “For Developers”
    • Enable “Developer Mode”

    ⚙️ Part Three: Configuring Flutter Project

    3.1 Install Correct Version of Flutter

    If you are using FVM:

    cd D:\Projects\rustdesk
    
    # Install Flutter 3.24.5
    fvm install 3.24.5
    
    # Use this version in the project
    fvm use 3.24.5
    
    # Verify version
    fvm flutter --version

    If your global Flutter version is incorrect (e.g., 3.35.7), you need to downgrade:

    # Navigate to Flutter SDK directory
    cd C:\flutter
    
    # Switch to 3.24.5
    git checkout 3.24.5
    
    # Update
    flutter doctor
    
    # Verify
    flutter --version

    3.2 Install flutter_rust_bridge_codegen

    # Install v1 version (used by RustDesk 1.43)
    cargo install flutter_rust_bridge_codegen --version 1.82.6

    3.3 Get Flutter Dependencies

    cd D:\Projects\rustdesk\flutter
    
    # If using FVM
    fvm flutter pub get
    
    # If using global Flutter
    flutter pub get

    🚀 Part Four: Compiling RustDesk

    4.1 Generate Flutter-Rust Bridge (if needed)

    cd D:\Projects\rustdesk
    
    # Check if generated files already exist
    Test-Path flutter\lib\generated_bridge.dart
    
    # If not or need to regenerate
    flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart

    4.2 Start Compilation

    Open PowerShell as Administrator (Important!), then:

    cd D:\Projects\rustdesk
    
    # Basic compilation
    python build.py --flutter
    
    # If using FVM, set PATH first
    $env:PATH = "$PWD\.fvm\flutter_sdk\bin;$env:PATH"
    python build.py --flutter

    Compilation Options:

    • <span>--flutter</span>: Compile Flutter version

    • <span>--portable</span>: Generate portable version

    • <span>--hwcodec</span>: Enable hardware encoding

    • <span>--skip-portable-pack</span>: Skip packaging step (recommended)

    Recommended Command:

    python build.py --flutter --skip-portable-pack

    4.3 Wait for Compilation to Complete

    The first compilation will take a long time (30-60 minutes) because it needs to:

    • Compile Rust code
    • Compile Flutter application
    • Download and replace Flutter Engine

    Upon successful compilation, it will display:

    ✓ Built build\windows\x64\runner\Release\rustdesk.exe

    📦 Part Five: Locating and Running the Compilation Results

    5.1 Location of Compiled Artifacts

    After successful compilation, the files are located at:

    D:\Projects\rustdesk\flutter\build\windows\x64\runner\Release\

    Main files:

    • <span>rustdesk.exe</span> – Main program

    • <span>*.dll</span> – Dependency library files

    • <span>data/</span> – Resource folder

    5.2 Run the Program

    cd D:\Projects\rustdesk\flutter\build\windows\x64\runner\Release
    .ustdesk.exe

    5.3 Packaging for Distribution (Optional)

    If you need to package it as a portable version:

    # Manually copy the entire Release folder
    xcopy /E /I "flutter\build\windows\x64\runner\Release" "rustdesk-portable"
    
    # Compress into zip
    Compress-Archive -Path rustdesk-portable -DestinationPath rustdesk-windows.zip

    ❗ Common Issues and Solutions

    Issue 1: Symlink Error

    Error Message:

    Building with plugins requires symlink support.
    Please enable Developer Mode in your system settings.

    Solution:

    1. Run <span>start ms-settings:developers</span>

    2. Enable “Developer Mode”
    3. Restart the terminal and run the compilation command as Administrator

    Issue 2: Flutter Version Mismatch

    Error Message:

    Flutter 3.35.7 ...
    fatal: please update version of ffigen in your dev_dependencies.

    Solution: Your Flutter version is too new; you need to use 3.24.5.

    # Method 1: Switch globally
    cd C:\flutter
    git checkout 3.24.5
    flutter doctor
    
    # Method 2: Use FVM
    fvm install 3.24.5
    fvm use 3.24.5

    Issue 3: IntoIntoDart Trait Error

    Error Message:

    error[E0277]: the trait bound `EventToUI: IntoIntoDart<_>` is not satisfied

    Solution: Incorrect version of flutter_rust_bridge, reinstall:

    cargo uninstall flutter_rust_bridge_codegen
    cargo install flutter_rust_bridge_codegen --version 1.82.6
    
    # Regenerate bridge
    flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart
    
    # Clean and recompile
    cd flutter
    flutter clean
    cd ..
    python build.py --flutter --skip-portable-pack

    Issue 4: Missing dylib_virtual_display.dll

    Error Message:

    FileNotFoundError: [WinError 3] ...dylib_virtual_display.dll

    Solution: This error can be ignored; the main program has compiled successfully. Add the <span>--skip-portable-pack</span> parameter:

    python build.py --flutter --skip-portable-pack

    The virtual display driver is an optional feature and does not affect normal usage.

    Issue 5: vcpkg Installation of aom is Slow

    Problem: Installing the aom library may take over 30 minutes.

    Solution:

    • Be patient; this is normal
    • Or use a proxy to speed up downloads
    • You can install other libraries first, and install aom last

    Issue 6: Insufficient Memory During Compilation

    Solution:

    # Limit the number of parallel compilation jobs
    $env:CARGO_BUILD_JOBS = "4"
    python build.py --flutter --skip-portable-pack

    🎯 Complete Compilation Process Summary

    # 1. Clone the code
    git clone --recurse-submodules https://github.com/rustdesk/rustdesk
    cd rustdesk
    
    # 2. Enable Developer Mode
    start ms-settings:developers
    
    # 3. Install the correct Flutter version
    fvm install 3.24.5
    fvm use 3.24.5
    
    # 4. Install flutter_rust_bridge
    cargo install flutter_rust_bridge_codegen --version 1.82.6
    
    # 5. Get dependencies
    cd flutter
    fvm flutter pub get
    cd ..
    
    # 6. Compile as Administrator (Important!)
    $env:PATH = "$PWD\.fvm\flutter_sdk\bin;$env:PATH"
    python build.py --flutter --skip-portable-pack
    
    # 7. Run the program
    cd flutter\build\windows\x64\runner\Release
    .ustdesk.exe

    🔗 Related Resources

    • RustDesk Official Documentation [7]

    • RustDesk GitHub [8]

    • Flutter Official Documentation [9]

    • Rust Official Documentation [10]

    ⚠️ Notes

    1. Must run compilation commands as Administrator

    2. Ensure Flutter version is 3.24.5, do not use newer or older versions

    3. First compilation takes a long time, please be patient

    4. Installation of aom library in vcpkg is slow, this is normal

    5. During compilation, Flutter Engine will be automatically downloaded, a good network connection is required

    6. It is recommended to use SSD, compilation speed will be much faster

    7. At least 20GB of disk space should be reserved

    🎉 Compilation Successful!

    After successful compilation, you can:

    • Directly run <span>rustdesk.exe</span> for testing

    • Package the <span>Release</span> folder for distribution

    • Modify the source code as needed and recompile
    • Contribute code to the RustDesk project

    Happy coding! 🚀

    Reference Links

    <span>[1]</span> Visual Studio Community 2022:https://visualstudio.microsoft.com/<span>[2]</span>rustup-init.exe:https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe<span>[3]</span>Git for Windows:https://git-scm.com/download/win<span>[4]</span>LLVM 15.0.2 (64-bit):https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.2/LLVM-15.0.2-win64.exe<span>[5]</span>Flutter SDK:https://docs.flutter.dev/release/archive<span>[6]</span>Python 3.11+:https://www.python.org/downloads/<span>[7]</span>RustDesk Official Documentation:https://rustdesk.com/docs/<span>[8]</span>RustDesk GitHub:https://github.com/rustdesk/rustdesk<span>[9]</span>Flutter Official Documentation:https://docs.flutter.dev/<span>[10]</span>Rust Official Documentation: https://www.rust-lang.org/

    Content is original and optimized by AI.

    Leave a Comment