Skip to content

Compiling TigerVNC for Windows

Danny Park edited this page Jun 30, 2020 · 9 revisions

Using MSYS2 and Mingw-w64 to compile TigerVNC 64 bit on Windows 10 64 bit

Last Updated: 30 June 2020

This wiki was initially started because at least one developer realized there was no straight forward approach to get TigerVNC compiling for Windows and test contributions to the project. Feel free to update this with new and/or better information.

Install MSYS2

MSYS2 is a self proclaimed "software distro and building platform for Windows". Please go to their website https://www.msys2.org/, download the one click installer and run it.

Install prerequisite packages

pacman -S mingw-w64-x86_64-cmake

pacman -S mingw-w64-x86_64-fltk

pacman -S mingw-w64-x86_64-gnutls

pacman -S mingw-w64-x86_64-gcc

pacman -S mingw-w64-x86_64-make

pacman -S mingw-w64-x86_64-pixman

Clone the TigerVNC project

git clone https://github.com/TigerVNC/tigervnc.git

Patch TigerVNC

Work in process to get necessary changes incorporated into the main branch. See pull request #1039 (https://github.com/TigerVNC/tigervnc/pull/1039) for the first changes to be incorporated. The patch here is a temporary fix.

Patch for including dll's in the installer:

From 65a09ba84ed84cc96cb946681ae94233b358d6f9 Mon Sep 17 00:00:00 2001
From: Danny Park <[email protected]>
Date: Tue, 9 Jun 2020 13:37:30 -0400
Subject: [PATCH] Include required dll's in the installer.

---
 cmake/BuildPackages.cmake |  3 +++
 release/tigervnc.iss.in   | 28 ++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/cmake/BuildPackages.cmake b/cmake/BuildPackages.cmake
index 1f251929..511ab49c 100644
--- a/cmake/BuildPackages.cmake
+++ b/cmake/BuildPackages.cmake
@@ -8,6 +8,9 @@
 
 if(WIN32)
 
+find_path(TEMP_PATH libunistring-2.dll)
+set(WIN_DLL_PATH "${TEMP_PATH}" CACHE PATH "Path where Windows DLL files are located for installer.")
+
 if(CMAKE_SIZEOF_VOID_P MATCHES 8)
   set(INST_NAME ${CMAKE_PROJECT_NAME}64-${VERSION})
   set(INST_DEFS -DWIN64)
diff --git a/release/tigervnc.iss.in b/release/tigervnc.iss.in
index 58501488..9bd251b2 100644
--- a/release/tigervnc.iss.in
+++ b/release/tigervnc.iss.in
@@ -24,6 +24,34 @@ LicenseFile=@CMAKE_SOURCE_DIR@\LICENCE.txt
 Name: "{sys}\config\systemprofile\Desktop"
 
 [Files]
+#ifndef BUILD_STATIC
+Source: "@WIN_DLL_PATH@/libintl-8.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace; 
+Source: "@WIN_DLL_PATH@/libiconv-2.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace;
+Source: "@WIN_DLL_PATH@/mgwfltknox-1.3.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace;
+Source: "@WIN_DLL_PATH@/zlib1.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace;
+Source: "@WIN_DLL_PATH@/libjpeg-8.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace;
+Source: "@WIN_DLL_PATH@/libgcc_s_seh-1.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace;
+Source: "@WIN_DLL_PATH@/libstdc++-6.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace;
+Source: "@WIN_DLL_PATH@/libwinpthread-1.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace;
+Source: "@WIN_DLL_PATH@/libpixman-1-0.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace;
+#ifdef ENABLE_GNUTLS
+Source: "@WIN_DLL_PATH@/libffi-7.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace; 
+Source: "@WIN_DLL_PATH@/libgmp-10.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace; 
+Source: "@WIN_DLL_PATH@/libgnutls-30.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace; 
+Source: "@WIN_DLL_PATH@/libhogweed-6.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace;  
+Source: "@WIN_DLL_PATH@/libidn2-0.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace; 
+Source: "@WIN_DLL_PATH@/libnettle-8.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace; 
+Source: "@WIN_DLL_PATH@/libp11-kit-0.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace; 
+Source: "@WIN_DLL_PATH@/libtasn1-6.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace; 
+Source: "@WIN_DLL_PATH@/libunistring-2.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace;
+#endif
+#else
+Source: "@WIN_DLL_PATH@/libffi-7.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace;
+Source: "@WIN_DLL_PATH@/libp11-kit-0.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace; 
+Source: "@WIN_DLL_PATH@/libunistring-2.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace;
+Source: "@WIN_DLL_PATH@/libintl-8.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace; 
+Source: "@WIN_DLL_PATH@/libiconv-2.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace;
+#endif
 #ifdef BUILD_WINVNC
 Source: "@CMAKE_CURRENT_BINARY_DIR@\win\winvnc\winvnc4.exe"; DestDir: "{app}"; Flags: ignoreversion restartreplace; 
 Source: "@CMAKE_CURRENT_BINARY_DIR@\win\wm_hooks\wm_hooks.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace; 
-- 
2.27.0.windows.1

Create a build directory in the tigervnc repo

Start MSYS2-MinGW 64 bit

cd tigervnc

mkdir build

cd build

Configure the build environment and run it

cmake -G "MinGW Makefiles" ../

mingw32-make.exe

Create the Windows Installer

Creating the installer requires the above cmake -G "MinGW Makefiles" ../ command.

Install Inno Setup 6 from https://jrsoftware.org/isinfo.php. (any time before running mingw32-make.exe installer).

Add the path to your MinGW 64-bit path. This only changes your path for the current terminal session. This needs to be run every time before the installer is created.

export PATH=/c/Program\ Files\ \(x86\)/Inno\ Setup\ 6/:$PATH

Create the installer.

mingw32-make.exe installer

Note for compatibility with Windows 7

Apparently the windows kernel32.dll exports a reference to CreateProcessAsUserA in Windows 10 but not in Windows 7. The libkernel32.a for newer versions of crt-git contain that export. That causes a runtime error in Windows 7. Version 6 does not have that reference so it properly links to advapi32.dll for Windows 7.

If you want a binary that is compatible with Windows 7, download mingw-w64-x86_64-crt-git-6.0.0.5225.fb06a4bf-1-any.pkg.tar.xz from http://repo.msys2.org/mingw/x86_64/ and then install it with the following command:

pacman -U mingw-w64-x86_64-crt-git-6.0.0.5225.fb06a4bf-1-any.pkg.tar.xz