Skip to content

Build: Build DBus on Windows

Lars Toenning edited this page Oct 9, 2023 · 1 revision

On Windows, the default Qt installation includes QtDBus, but not the DBus library that it depends on.

The following describes the steps to create the DBus binaries for Windows, that are kept in swift's externals git repository.

Building from source

  • Download and install CMake.

  • Download and extract the libexpat and libdbus source code.

    • At the time of writing, both the latest stable release and the master branch of libexpat fail to build on Windows, so we fall back to the previous stable version (2.1.1).
    • MinGW binaries of libexpat are already part of the default MinGW itself.
  • Visual Studio Command Prompt:

    cmake -G "Visual Studio 15 2017" -DCMAKE_INSTALL_PREFIX=C:\expat-msvc32 C:\expat-sources
    msbuild install.vcxproj /p:Configuration=Release

    cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=C:\expat-msvc64 C:\expat-sources
    msbuild install.vcxproj /p:Configuration=Release

    cmake -G "Visual Studio 15 2017" -DCMAKE_INSTALL_PREFIX=C:\dbus-msvc32
        -DEXPAT_INCLUDE_DIR=C:\expat-msvc32\include
        -DEXPAT_LIBRARY=C:\expat-msvc32\lib\expat.lib C:\dbus-sources\cmake
    msbuild install.vcxproj /p:Configuration=Release

    cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=C:\dbus-msvc64
        -DEXPAT_INCLUDE_DIR=C:\expat-msvc64\include
        -DEXPAT_LIBRARY=C:\expat-msvc64\lib\expat.lib C:\dbus-sources\cmake
    msbuild install.vcxproj /p:Configuration=Release
  • MinGW Command Prompt:
cmake -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX=C:\dbus-mingw32 C:\dbus-sources\cmake
mingw32-make install

Verbose vs. secure builds

The default DBus CMake build includes unit tests, asserts, and verbose mode, which help with debugging but render the library insecure. To build secure binaries appropriate for deployment to end-users, use these cmake arguments:

-DDBUS_BUILD_TESTS=OFF -DDBUS_DISABLE_ASSERT=ON -DDBUS_ENABLE_VERBOSE_MODE=OFF

Error messages

Some error messages you see when the libdbus libs are missing (also posted here so you can search by the terms)

Cannot find libdbus-1 in your system to resolve symbol 'dbus_get_local_machine_id'.
Debug Error!

Program: P:\Qt\5.9.2\msvc2015\bin\Qt5Cored.dll
Module: 5.9.2
File: qdbus_symbols.cpp
Line: 142
Clone this wiki locally