How to Compile Nextcloud Desktop App on Windows (MSVC)

In this guide, we will walk through the complete process of setting up the environment, compiling dependencies, and building the Nextcloud Desktop Client from source using MSVC 2022 and Qt 6.

1. Install Qt Components

First, download the AQT INSTALL command-line tool: Download aqt_x64.exe

Use the tool to install Qt 6.9.0 and its required modules by running the following in PowerShell:

aqt install-qt windows desktop 6.9.0 win64_msvc2022_64 -m qtwebengine qtshadertools qt5compat qtwebsockets --outputdir E:/Dev/Tools/Qt-Portable

2. Download Pre-compiled Third-party Dependencies

Download the following libraries and extract them to E:/Dev/Libs:


3. Manually Compile Third-party Dependencies

Note: All commands in this section should be executed within a Developer PowerShell for VS 2022 environment.

3.1 ECM (Extra CMake Modules)

git clone https://invent.kde.org/frameworks/extra-cmake-modules.git --depth 1
cmake -B Build -S . -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="E:/Dev/Tools/Qt-Portable/6.9.0/msvc2022_64" -DCMAKE_INSTALL_PREFIX="E:/Dev/Libs/kde-ecm"
cmake --build build --target install

3.2 libLZMA

git clone https://github.com/kobolabs/liblzma.git --depth 1
cmake -B build -S . -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="E:/Dev/Libs/liblzma-install"
cmake --build build --target install

3.3 bzip2

git clone https://github.com/libarchive/bzip2.git --depth 1
cmake -B build -S . -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="E:/Dev/Libs/bzip2-install"
cmake --build build --target install

3.4 KDSingleApplication

git clone https://github.com/KDAB/KDSingleApplication.git --depth 1
cmake -B Build -S . -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="E:/Dev/Tools/Qt-Portable/6.9.0/msvc2022_64;E:/Dev/Libs/kde-ecm" -DCMAKE_INSTALL_PREFIX="E:/Dev/Libs/KDSingleApplication"
cmake --build build --target install

3.5 qtkeychain

git clone https://github.com/frankosterfeld/qtkeychain.git --depth 1
cmake -B Build -S . -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="E:/Dev/Tools/Qt-Portable/6.9.0/msvc2022_64;E:/Dev/Libs/kde-ecm" -DCMAKE_INSTALL_PREFIX="E:/Dev/Libs/qtkeychain"
cmake --build build --target install

3.6 KArchive

git clone https://invent.kde.org/frameworks/karchive.git --depth 1
cmake -B Build -S . -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="E:/Dev/Tools/Qt-Portable/6.9.0/msvc2022_64;E:/Dev/Libs/kde-ecm;E:/Dev/Libs/bzip2-install;E:/Dev/Libs/liblzma-install;E:/Dev/Libs/zlib-ng-win-x86-64-compat;E:/Dev/Libs/openssl-1.1/x64" -DCMAKE_INSTALL_PREFIX="E:/Dev/Libs/kf6archive" -DWITH_LIBZSTD=OFF
cmake --build build --target install

3.7 SQLite3

Download the source and run the build script:

curl https://sqlite.org/2026/sqlite-src-3530100.zip -o E:/Dev/Libs/sqlite-src.zip
Expand-Archive E:/Dev/Libs/sqlite-src.zip -DestinationPath E:/Dev/Libs/
# Enter the directory and build
./make.bat

3.8 libp11

Clone: git clone https://github.com/OpenSC/libp11.git --depth 1

Create Config: Create libp11.pc in the root folder:

prefix=E:/Dev/Libs/libp11
exec_prefix=${prefix}
libdir=${prefix}/src
includedir=${prefix}/src
Name: libp11
Version: 0.4.12
Libs: -L"${libdir}" -llibp11
Cflags: -I"${includedir}"

Code Fix: In src/util_uri.c, comment out the legacy calls around line 40:

#ifndef HAVE_X509_GET0_NOTBEFORE
//# define X509_get0_notBefore X509_get_notBefore
#endif

Export Fix: In src/libp11.exports, use ; to comment out PKCS11_evp_pkey_sign and PKCS11_evp_pkey_decrypt.

Build:

nmake -f Makefile.mak OPENSSL_DIR="E:/Dev/Libs/openssl-1.1/x64" BUILD_FOR=WIN64

4. Compiling the Nextcloud App

Prerequisites

  • Install Inkscape: winget install Inkscape.Inkscape --interactive
  • Download icoutils and extract to E:/Dev/Tools/icoutils-0.32.3-x86_64.

Source Code Adjustments

Modify src/libsync/clientsideencryption.cpp: Around line 43, add Windows header fixes to prevent macro conflicts:

#ifdef Q_OS_WIN
#include <windows.h>
#include <wincrypt.h>
#undef ISSUER
#undef SUBJECT
#undef X509_NAME
#undef X509_CERT_PAIR
#undef X509_EXTENSIONS
#undef OCSP_REQUEST
#undef OCSP_RESPONSE
#endif

Modify src/libsync/vfs/cfapi/shellext/thumbnailprovider.cpp: Add these headers at the top:

#include <ntstatus.h>
#define WIN32_NO_STATUS

Final Build Command

In the desktop-master root directory:

$env:PKG_CONFIG_PATH="E:/Dev/Libs/libp11"
cmake -B build -S . -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="/D_CRT_SECURE_NO_WARNINGS /D_SILENCE_CXX20_OLD_SHARED_PTR_ATOMIC_SUPPORT_DEPRECATION_WARNING /DOPENSSL_SUPPRESS_DEPRECATED /DEHsc" -DCMAKE_PREFIX_PATH="E:/Dev/Libs/kde-ecm;E:/Dev/Tools/Qt-Portable/6.9.0/msvc2022_64;E:/Dev/Libs/openssl-1.1/x64;E:/Dev/Libs/zlib-ng-win-x86-64-compat;E:/Dev/Libs/sqlite-src-3530100;E:/Dev/Libs/KDSingleApplication;E:/Dev/Libs/qtkeychain;E:/Dev/Libs/kf6archive" -DLIBP11_INCLUDE_DIR="E:/Dev/Libs/libp11/src" -DLIBP11_LIBRARY="E:/Dev/Libs/libp11/src/libp11.lib" -DSQLite3_INCLUDE_DIR="E:/Dev/Libs/sqlite-src-3530100" -DSQLite3_LIBRARY="E:/Dev/Libs/sqlite-src-3530100/sqlite3.lib" -DSVG_CONVERTER="C:/Program Files/Inkscape/bin/inkscape.exe" -DIcoTool_EXECUTABLE="E:/Dev/Tools/icoutils-0.32.3-x86_64/bin/icotool.exe" -DCMAKE_INSTALL_PREFIX="E:/desktop-master/install" -DBUILD_WITH_WEBENGINE=OFF -DBUILD_TESTING=OFF
cmake --build build --target install

5. Manual Deployment

After a successful build, follow these steps to run the application:

  1. Navigate to E:/desktop-master/install/bin and run nextcloud.exe.
  2. Dependencies: If errors occur regarding missing DLLs, copy the required Qt runtime files from E:\Dev\Tools\Qt-Portable\6.9.0\msvc2022_64\bin to your bin folder.
  3. Third-party DLLs: Collect relevant DLLs from the build directories of the dependencies in Section 3 and place them in the bin folder.
  4. Plugins: Create a folder named platforms inside the bin directory. Copy qwindows.dll from E:\Dev\Tools\Qt-Portable\6.9.0\msvc2022_64\plugins\platforms\ into it.

Leave a Reply

Your email address will not be published. Required fields are marked *