Skip to content

Windows x64

This article explains how to setup the dependency builder and add new dependencies.

Setting up a virtual machine

The dependency builder is best setup on a clean virtual machine. Use any hypervisor that you like. You should reserve at least 16GB of RAM and 200GB of free disk space for it.

  • Setup a new VM and install Windows on it (Windows 11 or Windows Server 2019). For Windows Server, make sure to install the Desktop version.
  • Run an administrator prompt and grab the script: curl https://projects.blender.org/blender/blender/raw/branch/main/build_files/build_environment/windows/vmprep.cmd.txt -o %USERPROFILE%/vmprep.cmd
  • Then run it using %USERPROFILE%/vmprep.cmd. It can take a few hours. Most applications are using an unattended install. For the CUDA Toolkit and the HIP SDK make sure to change the installation path as noted by the script.
  • After the installation is complete, you can build the Blender dependencies by opening up a x64 Native Tools Command Prompt for VS 2019 and run cd c:\db && vmbuild.cmd. This can take a few more hours but it's good to test the installation was successful before continuing adding new libraries.

Adding and building new dependencies

This section provides a template for how to add a new dependency (LIBRARY) to Blender's make deps. You can find the mentioned files in C:\blendergit\blender\build_files\build_environment\cmake\.

Preparations

  • Add a new section for the library in versions.cmake. Copy an existing one and modify it or take this as a basis:

    set(LIBRARY_VERSION 1.0.0)
    set(LIBRARY_COMMIT "e2d886a104") # Only needed when we require a certain commit
    set(LIBRARY_NAME "Library Name")
    set(LIBRARY_URI [URL]{LIBRARY_VERSION}.tar.gz)
    set(LIBRARY_HASH [HASH OF SOURCE ARCHIVE])
    set(LIBRARY_HASH_TYPE MD5)
    set(LIBRARY_FILE [LIBRARY]-${LIBRARY_VERSION}.tar.gz)
    set(LIBRARY_HOMEPAGE [URL])
    set(LIBRARY_LICENSE SPDX:Apache-2.0)
    set(LIBRARY_COPYRIGHT "Copyright 2025 Library authors")
    
  • In downloads.cmake add download_source(LIBRARY) at the bottom.

Get the source code

  • Open a x64 Native Tools Command Prompt for VS 2019 terminal, go to C:\db and run vmbuild.bat. Check if the script downloads the source archive of the new library.

    Hash errors

    If you get a hash error, put the proper hash into versions.cmake.

    If you missed the error in the output open C:\db\build\S\VS1564R\CMakeCache.txt and enable FORCE_CHECK_HASH and it will check every hash, every time you run CMake.

Compile the new library

  • Copy an existing library file like tiff.cmake and rename it to [library].cmake.

    • Open the new file and adjust all library names inside for the new library. Be careful to rename both lower and upper case names properly.
    • Empty [LIBRARY]_EXTRA_ARGS, proper build flags can be added if known already or done later.
    • Adjust build/copy code in [library].cmake for Release and Debug.

      C vs. C++ libraries

      C libs have the same ABI for MSVC ie. it'll export library_func1234 the same way between release and debug libs so we only need the release version.

      C++ libs export things like libary_debug_func1234_int_int_void (simplified for brevity), since C++ encodes the arguments and return type into the function name. This means debug and release have different exports, and we have to build both versions.

      Therefore put a C lib into a if(NOT WIN32 OR BUILD_MODE STREQUAL Release) check at the bottom of [library].cmake to prevent it from being built twice.

  • Example of what the file could look like at this point:

    # SPDX-FileCopyrightText: 2002-2025 Blender Authors
    #
    # SPDX-License-Identifier: GPL-2.0-or-later
    
    set(LIBRARY_EXTRA_ARGS
    
    )
    
    ExternalProject_Add(external_library
      URL file://${PACKAGE_DIR}/${LIBRARY_FILE}
      DOWNLOAD_DIR ${DOWNLOAD_DIR}
      URL_HASH ${LIBRARY_HASH_TYPE}=${LIBRARY_HASH}
      PREFIX ${BUILD_DIR}/library
      CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR}
      CMAKE_ARGS
        -DCMAKE_INSTALL_PREFIX=${LIBDIR}/library
        ${DEFAULT_CMAKE_FLAGS}
        ${LIBRARY_EXTRA_ARGS}
    
      INSTALL_DIR ${LIBDIR}/library
    )
    
    add_dependencies(
      external_library
      external_other_dependencies_of_library
    )
    if(WIN32)
      ExternalProject_Add_Step(external_library after_install
        COMMAND
          ${CMAKE_COMMAND} -E copy_directory
          ${LIBDIR}/library/
          ${HARVEST_TARGET}/library/
        DEPENDEES install
      )
    else()
      harvest(external_library library/include library/include "*.h")
      harvest(external_library library/lib library/lib "*.a")
    endif()
    
  • Add the new [library].cmake file to C:\blendergit\blender\build_files\build_environment\CMakeLists.txt
  • Run vmbuild.bat again and check for errors.

    Clean build

    You can run nuke [library] before running vmbuild.bat to ensure a clean build.

  • After building, head over to C:\db\build\output\Win64_vc15\[library]\ and check what was built.
    • Check if the build folder contains unnecessary binaries, tests or options.
    • Adjust LIBRARY_EXTRA_ARGS in [library].cmake if build options exist to disable the unnecessary components.
    • It's best practise to specify all possible options and not rely on the current defaults.
    • If the result is only a single library file, add -DCMAKE_DEBUG_POSTFIX=_d so that release and debug are not mixed.
  • Nuke the library folder and rebuild if needed.
  • Copy the libs to the lib folder on the workstation to proceed with the Blender integration.