Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUACAMOLE-1841: Implement MinGW build for libguac. #485

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Windows Build

# Automatically verify pull requests
on: [pull_request]

# Limit to only one build for a given PR source branch at a time,
# cancelling any in-progress builds
concurrency:
group: windows-build-${{ github.head_ref }}
cancel-in-progress: true

jobs:

# This runs on a github-hosted runner, guaranteed fresh for every job run.
# Git, msys2, and other tools come preinstalled. For more, see
# https://github.com/actions/runner-images/blob/main/images/win/Windows2022-Readme.md
windows-build:
name: Build guacamole-server on windows server 2022
runs-on: windows-2022
steps:

# TODO: Install libtelnet from source - it's not available in msys2
- name: Update MSYS2 repos and install dependencies
shell: powershell
run: |
C:\\msys64\\usr\\bin\\pacman.exe --noconfirm -S git base-devel mingw-w64-x86_64-gcc mingw-w64-x86_64-autotools mingw-w64-x86_64-libtool libtool
C:\\msys64\\usr\\bin\\pacman.exe --noconfirm -S mingw-w64-x86_64-cunit mingw-w64-x86_64-make mingw-w64-x86_64-python
C:\\msys64\\usr\\bin\\pacman.exe --noconfirm -S mingw-w64-x86_64-cairo
C:\\msys64\\usr\\bin\\pacman.exe --noconfirm -S mingw-w64-x86_64-dlfcn
C:\\msys64\\usr\\bin\\pacman.exe --noconfirm -S mingw-w64-x86_64-freerdp
C:\\msys64\\usr\\bin\\pacman.exe --noconfirm -S mingw-w64-x86_64-libssh2
C:\\msys64\\usr\\bin\\pacman.exe --noconfirm -S mingw-w64-x86_64-libvncserver
C:\\msys64\\usr\\bin\\pacman.exe --noconfirm -S mingw-w64-x86_64-libwebsockets
C:\\msys64\\usr\\bin\\pacman.exe --noconfirm -S mingw-w64-x86_64-libjpeg-turbo
C:\\msys64\\usr\\bin\\pacman.exe --noconfirm -S mingw-w64-x86_64-libpng
C:\\msys64\\usr\\bin\\pacman.exe --noconfirm -S mingw-w64-x86_64-libgxps
C:\\msys64\\usr\\bin\\pacman.exe --noconfirm -S mingw-w64-x86_64-libtool
C:\\msys64\\usr\\bin\\pacman.exe --noconfirm -S mingw-w64-x86_64-libwebp
C:\\msys64\\usr\\bin\\pacman.exe --noconfirm -S mingw-w64-x86_64-openssl
C:\\msys64\\usr\\bin\\pacman.exe --noconfirm -S mingw-w64-x86_64-pango
C:\\msys64\\usr\\bin\\pacman.exe --noconfirm -S mingw-w64-x86_64-pulseaudio

C:\\msys64\\usr\\bin\\pacman.exe -Q

- name: Configure git to not mangle line endings
run: git config --global core.autocrlf input

- name: Checkout guacamole-server source
uses: actions/checkout@v4

- name: Build guacamole-server
shell: C:\\msys64\\usr\\bin\\bash.exe --login -eo pipefail -o igncr '{0}'
run: |

SERVER_BASE=`cygpath -u '${{ github.workspace }}'`
cd "$SERVER_BASE"

autoreconf -fi

export MINGW_ARCH="mingw64"
export PKG_CONFIG_PATH="/mingw64/lib/pkgconfig:/usr/lib/pkgconfig"
export PATH="$PATH:/mingw64/bin:/usr/bin"
export LDFLAGS="-L/mingw64/bin/ -L/usr/bin/ -L/mingw64/lib -lws2_32"
export CFLAGS="-isystem/mingw64/include/ \
-I/mingw64/include/pango-1.0 \
-I/mingw64/include/glib-2.0/ \
-I/mingw64/lib/glib-2.0/include/ \
-I/mingw64/include/harfbuzz/ \
-I/mingw64/include/cairo/ \
-I/mingw64/include/winpr2 \
-Wno-error=expansion-to-defined -Wno-error=attributes -Wno-incompatible-pointer-types"
./configure --with-windows --disable-guacenc --disable-guacd --disable-guaclog
make
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ nbproject/
# Compilation database, as may be generated by tools like Bear
.cache/
compile_commands.json

# Crash Reports
**/*.stackdump
116 changes: 116 additions & 0 deletions README-windows-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Building guacamole-server for Windows
Certain portions of `guacamole-server` can be built using MinGW on Windows, specifically the libguac libraries. `guacd` itself relies on `fork()` and other functionality that has no equivalent in Windows. Theoretically, Cygwin could provide a compatibility layer for these missing functions, but so far attempts to implement such a build have not resulted in a functional `guacd`.

This document will walk you through a known-working set of steps for building the libguac libraries for a Windows target. The following build steps were tested on a Windows Server 2022 x86_64 build node.

### Build Steps
1. Install MSYS2 (version 20230718 used here)
2. Install MSYS2 packages:
* autoconf-wrapper
* automake-wrapper
* diffutils
* git
* libtool
* libedit-devel
* make
* pkg-config
* wget
* msys2-runtime-devel
* mingw-w64-x86_64-gcc
* mingw-w64-x86_64-libwebsockets
* mingw-w64-x86_64-libtool
* mingw-w64-x86_64-dlfcn
* mingw-w64-x86_64-pkg-config
* mingw-w64-x86_64-cairo
* mingw-w64-x86_64-gcc
* mingw-w64-x86_64-gdb
* mingw-w64-x86_64-libpng
* mingw-w64-x86_64-libjpeg-turbo
* mingw-w64-x86_64-freerdp (version < 3)
* mingw-w64-x86_64-freetds
* mingw-w64-x86_64-postgresql
* mingw-w64-x86_64-libmariadbclient
* mingw-w64-x86_64-libvncserver
* mingw-w64-x86_64-dlfcn
* mingw-w64-x86_64-libgcrypt
* mingw-w64-x86_64-libgxps
* mingw-w64-x86_64-libwebsockets
* mingw-w64-x86_64-libwebp
* mingw-w64-x86_64-libssh2
* mingw-w64-x86_64-openssl
* mingw-w64-x86_64-libvorbis
* mingw-w64-x86_64-pulseaudio
* mingw-w64-x86_64-zlib
*
3. Build `libtelnet` from source using MSYS2 bash shell
```
export PKG_CONFIG_PATH="/mingw64/lib/pkgconfig"
export PATH="$PATH:/mingw64/bin:/usr/bin"
curl -s -L https://github.com/seanmiddleditch/libtelnet/releases/download/0.23/libtelnet-0.23.tar.gz | tar xz
cd libtelnet-0.23
autoreconf -fi

./configure --prefix=/mingw64 --disable-static --disable-util LDFLAGS="-Wl,-no-undefined -L/mingw64/bin/ -L/mingw64/lib" || cat config.log
cat config.log

make LDFLAGS="-no-undefined"
make install
```
4. Fix DLL prefixes so that the build can link against them, e.g. using this script
```
#!/bin/bash

set -e
set -x

# Enable fancy pattern matching on filenames (provides wildcards that can match
# multiple contiguous digits, among others)
shopt -s extglob

# Strip architecture suffix
for LIB in /mingw64/bin/lib*-x64.dll; do
ln -sfv "$LIB" "$(echo "$LIB" | sed 's/-x64.dll$/.dll/')"
done

# Automatically add symlinks that strip the library version suffix
for LIB in /mingw64/bin/lib*-+([0-9]).dll; do
ln -sfv "$LIB" "$(echo "$LIB" | sed 's/-[0-9]*\.dll$/.dll/')"
done

# Automatically add symlinks that strip the library version suffix
for LIB in /mingw64/bin/lib*([^0-9.])@([^0-9.-])+([0-9]).dll; do
ln -sfv "$LIB" "$(echo "$LIB" | sed 's/[0-9]*\.dll$/.dll/')"
done

```
5. Build `guacamole-server` from source using MSYS2 bash shell
```
export PKG_CONFIG_PATH="/mingw64/lib/pkgconfig:/usr/lib/pkgconfig"
export PATH="$PATH:/mingw64/bin:/usr/bin"

# FIXME: Update this to check out master once this PR is ready for merge
git clone https://github.com/jmuehlner/guacamole-server.git
cd guacamole-server
git checkout GUACAMOLE-1841-cygwin-build-clean

autoreconf -fi
export LDFLAGS="-L/mingw64/bin/ -L/usr/bin/ -L/mingw64/lib -lws2_32"
export CFLAGS="-isystem/mingw64/include/ \
-I/mingw64/include/pango-1.0 \
-I/mingw64/include/glib-2.0/ \
-I/mingw64/lib/glib-2.0/include/ \
-I/mingw64/include/harfbuzz/ \
-I/mingw64/include/cairo/ \
-I/mingw64/include/freerdp2 \
-I/mingw64/include/winpr2 \
-Wno-error=expansion-to-defined
-Wno-error=attributes"

./configure --prefix=/mingw64 --with-windows --disable-guacenc --disable-guacd --disable-guaclog || cat config.log

make
make install
```

## Closing Notes
FIXME: Update this document to explain how to configure fonts under Windows once I figure it out.
Loading
Loading