Skip to content

Commit 25990b0

Browse files
authored
Fix Windows/MSYS2/MinGW64 build failures (issue #280) (#355)
* Fix Windows/MSYS2/MinGW64 build failures (issue #280) Add MSYS environment support to configure.ac so users building from the MSYS shell get proper Windows configuration (winsock2.h, ws2_32 lib) instead of falling through to the Unix case (arpa/inet.h). Changes: - configure.ac: Add *-msys* case with Windows config and warning about msys-2.0.dll dependency - configure.ac: Add host triplet and Windows build status to summary - appveyor.yml: Add MSYS environment to CI matrix alongside MinGW64 - README.md: Add Windows/MSYS2 build section with step-by-step instructions and explanation of shell differences * Migrate Windows CI from AppVeyor to GitHub Actions Integrate Windows/MSYS2 builds into the existing verify job matrix instead of using a separate AppVeyor configuration. This consolidates all CI into GitHub Actions. - Add MINGW64 and MSYS matrix entries with msys2 shell - Add MSYS2 setup and package installation steps - Add Windows-specific libmicrohttpd build with --enable-poll=no - Remove AppVeyor configuration and badge * Fix missing shell parameter in matrix include entries Include entries don't inherit matrix defaults, so each needs an explicit shell value to work with the defaults.run.shell setting. * Fix shell for steps that run before MSYS2 setup The git checkout and failure-handling steps need explicit shell: bash since they may run before MSYS2 is set up or if MSYS2 setup fails. * Fix MSYS package: use libcurl-devel for test headers The curl package doesn't include development headers needed for compiling tests. Use libcurl-devel which provides curl/curl.h. * Fix MSYS package: add libgnutls-devel for SSL tests The SSL tests (ssl_base, ssl_with_protocol_priorities, ssl_with_trust) were failing because GnuTLS wasn't installed in the MSYS environment.
1 parent 53bded0 commit 25990b0

File tree

4 files changed

+147
-30
lines changed

4 files changed

+147
-30
lines changed

.github/workflows/verify-build.yml

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ jobs:
2020
BUILD_TYPE: ${{ matrix.build-type }}
2121
CC: ${{ matrix.c-compiler }}
2222
CXX: ${{ matrix.cc-compiler }}
23+
defaults:
24+
run:
25+
shell: ${{ matrix.shell }}
2326
strategy:
2427
fail-fast: false
2528
matrix:
@@ -33,6 +36,7 @@ jobs:
3336
coverage: [coverage, nocoverage]
3437
linking: [dynamic, static]
3538
build-type: [classic]
39+
shell: [bash]
3640
exclude:
3741
- os: ubuntu-latest
3842
os-type: mac
@@ -62,6 +66,7 @@ jobs:
6266
cc-compiler: clang++-18
6367
debug: debug
6468
coverage: nocoverage
69+
shell: bash
6570
# This test gives false positives on newer versions of clang
6671
# and ubuntu-18.04 is not supported anymore on github
6772
#- test-group: extra
@@ -82,6 +87,7 @@ jobs:
8287
cc-compiler: clang++-18
8388
debug: debug
8489
coverage: nocoverage
90+
shell: bash
8591
- test-group: extra
8692
os: ubuntu-latest
8793
os-type: ubuntu
@@ -91,6 +97,7 @@ jobs:
9197
cc-compiler: clang++-18
9298
debug: debug
9399
coverage: nocoverage
100+
shell: bash
94101
- test-group: extra
95102
os: ubuntu-latest
96103
os-type: ubuntu
@@ -100,6 +107,7 @@ jobs:
100107
cc-compiler: clang++-18
101108
debug: debug
102109
coverage: nocoverage
110+
shell: bash
103111
- test-group: extra
104112
os: ubuntu-latest
105113
os-type: ubuntu
@@ -109,6 +117,7 @@ jobs:
109117
cc-compiler: g++-9
110118
debug: nodebug
111119
coverage: nocoverage
120+
shell: bash
112121
- test-group: extra
113122
os: ubuntu-latest
114123
os-type: ubuntu
@@ -118,6 +127,7 @@ jobs:
118127
cc-compiler: g++-10
119128
debug: nodebug
120129
coverage: nocoverage
130+
shell: bash
121131
- test-group: extra
122132
os: ubuntu-latest
123133
os-type: ubuntu
@@ -127,6 +137,7 @@ jobs:
127137
cc-compiler: g++-11
128138
debug: nodebug
129139
coverage: nocoverage
140+
shell: bash
130141
- test-group: extra
131142
os: ubuntu-latest
132143
os-type: ubuntu
@@ -136,6 +147,7 @@ jobs:
136147
cc-compiler: g++-12
137148
debug: nodebug
138149
coverage: nocoverage
150+
shell: bash
139151
- test-group: extra
140152
os: ubuntu-latest
141153
os-type: ubuntu
@@ -145,6 +157,7 @@ jobs:
145157
cc-compiler: g++-13
146158
debug: nodebug
147159
coverage: nocoverage
160+
shell: bash
148161
- test-group: extra
149162
os: ubuntu-latest
150163
os-type: ubuntu
@@ -154,6 +167,7 @@ jobs:
154167
cc-compiler: g++-14
155168
debug: nodebug
156169
coverage: nocoverage
170+
shell: bash
157171
- test-group: extra
158172
os: ubuntu-22.04
159173
os-type: ubuntu
@@ -163,6 +177,7 @@ jobs:
163177
cc-compiler: clang++-11
164178
debug: nodebug
165179
coverage: nocoverage
180+
shell: bash
166181
- test-group: extra
167182
os: ubuntu-22.04
168183
os-type: ubuntu
@@ -172,6 +187,7 @@ jobs:
172187
cc-compiler: clang++-12
173188
debug: nodebug
174189
coverage: nocoverage
190+
shell: bash
175191
- test-group: extra
176192
os: ubuntu-22.04
177193
os-type: ubuntu
@@ -181,6 +197,7 @@ jobs:
181197
cc-compiler: clang++-13
182198
debug: nodebug
183199
coverage: nocoverage
200+
shell: bash
184201
- test-group: extra
185202
os: ubuntu-latest
186203
os-type: ubuntu
@@ -190,6 +207,7 @@ jobs:
190207
cc-compiler: clang++-14
191208
debug: nodebug
192209
coverage: nocoverage
210+
shell: bash
193211
- test-group: extra
194212
os: ubuntu-latest
195213
os-type: ubuntu
@@ -199,6 +217,7 @@ jobs:
199217
cc-compiler: clang++-15
200218
debug: nodebug
201219
coverage: nocoverage
220+
shell: bash
202221
- test-group: extra
203222
os: ubuntu-latest
204223
os-type: ubuntu
@@ -208,6 +227,7 @@ jobs:
208227
cc-compiler: clang++-16
209228
debug: nodebug
210229
coverage: nocoverage
230+
shell: bash
211231
- test-group: extra
212232
os: ubuntu-latest
213233
os-type: ubuntu
@@ -217,6 +237,7 @@ jobs:
217237
cc-compiler: clang++-17
218238
debug: nodebug
219239
coverage: nocoverage
240+
shell: bash
220241
- test-group: extra
221242
os: ubuntu-latest
222243
os-type: ubuntu
@@ -226,6 +247,7 @@ jobs:
226247
cc-compiler: g++-14
227248
debug: nodebug
228249
coverage: nocoverage
250+
shell: bash
229251
- test-group: extra
230252
os: ubuntu-latest
231253
os-type: ubuntu
@@ -235,6 +257,7 @@ jobs:
235257
cc-compiler: clang++-18
236258
debug: nodebug
237259
coverage: nocoverage
260+
shell: bash
238261
- test-group: performance
239262
os: ubuntu-latest
240263
os-type: ubuntu
@@ -244,6 +267,7 @@ jobs:
244267
cc-compiler: g++-10
245268
debug: nodebug
246269
coverage: nocoverage
270+
shell: bash
247271
- test-group: performance
248272
os: ubuntu-latest
249273
os-type: ubuntu
@@ -253,6 +277,7 @@ jobs:
253277
cc-compiler: g++-10
254278
debug: nodebug
255279
coverage: nocoverage
280+
shell: bash
256281
- test-group: performance
257282
os: ubuntu-latest
258283
os-type: ubuntu
@@ -262,6 +287,7 @@ jobs:
262287
cc-compiler: g++-10
263288
debug: nodebug
264289
coverage: nocoverage
290+
shell: bash
265291
- test-group: extra
266292
os: ubuntu-latest
267293
os-type: ubuntu
@@ -271,6 +297,31 @@ jobs:
271297
cc-compiler: g++-10
272298
debug: debug
273299
coverage: nocoverage
300+
shell: bash
301+
- test-group: basic
302+
os: windows-latest
303+
os-type: windows
304+
msys-env: MINGW64
305+
shell: 'msys2 {0}'
306+
build-type: classic
307+
compiler-family: none
308+
c-compiler: gcc
309+
cc-compiler: g++
310+
debug: nodebug
311+
coverage: nocoverage
312+
linking: dynamic
313+
- test-group: basic
314+
os: windows-latest
315+
os-type: windows
316+
msys-env: MSYS
317+
shell: 'msys2 {0}'
318+
build-type: classic
319+
compiler-family: none
320+
c-compiler: gcc
321+
cc-compiler: g++
322+
debug: nodebug
323+
coverage: nocoverage
324+
linking: dynamic
274325
steps:
275326
- name: Checkout repository
276327
uses: actions/checkout@v4
@@ -282,8 +333,29 @@ jobs:
282333
# If this run was triggered by a pull request event, then checkout
283334
# the head of the pull request instead of the merge commit.
284335
- run: git checkout HEAD^2
336+
shell: bash
285337
if: ${{ github.event_name == 'pull_request' }}
286-
338+
339+
- name: Setup MSYS2
340+
if: ${{ matrix.os-type == 'windows' }}
341+
uses: msys2/setup-msys2@v2
342+
with:
343+
msystem: ${{ matrix.msys-env }}
344+
update: true
345+
install: >-
346+
autotools
347+
base-devel
348+
349+
- name: Install MinGW64 packages
350+
if: ${{ matrix.os-type == 'windows' && matrix.msys-env == 'MINGW64' }}
351+
run: |
352+
pacman --noconfirm -S --needed mingw-w64-x86_64-{toolchain,libtool,make,pkg-config,libsystre,doxygen,gnutls,graphviz,curl}
353+
354+
- name: Install MSYS packages
355+
if: ${{ matrix.os-type == 'windows' && matrix.msys-env == 'MSYS' }}
356+
run: |
357+
pacman --noconfirm -S --needed msys2-devel gcc make libcurl-devel libgnutls-devel
358+
287359
- name: Install Ubuntu test sources
288360
run: |
289361
sudo add-apt-repository ppa:ubuntu-toolchain-r/test ;
@@ -395,6 +467,7 @@ jobs:
395467
with:
396468
path: libmicrohttpd-0.9.77
397469
key: ${{ matrix.os }}-${{ matrix.c-compiler }}-libmicrohttpd-0.9.77-pre-built
470+
if: ${{ matrix.os-type != 'windows' }}
398471

399472
- name: Build libmicrohttpd dependency (if not cached)
400473
run: |
@@ -403,10 +476,21 @@ jobs:
403476
cd libmicrohttpd-0.9.77 ;
404477
./configure --disable-examples ;
405478
make ;
406-
if: steps.cache-libmicrohttpd.outputs.cache-hit != 'true'
479+
if: ${{ matrix.os-type != 'windows' && steps.cache-libmicrohttpd.outputs.cache-hit != 'true' }}
407480

408481
- name: Install libmicrohttpd
409482
run: cd libmicrohttpd-0.9.77 ; sudo make install ;
483+
if: ${{ matrix.os-type != 'windows' }}
484+
485+
- name: Build and install libmicrohttpd (Windows)
486+
if: ${{ matrix.os-type == 'windows' }}
487+
run: |
488+
curl https://s3.amazonaws.com/libhttpserver/libmicrohttpd_releases/libmicrohttpd-0.9.77.tar.gz -o libmicrohttpd-0.9.77.tar.gz
489+
tar -xzf libmicrohttpd-0.9.77.tar.gz
490+
cd libmicrohttpd-0.9.77
491+
./configure --disable-examples --enable-poll=no
492+
make
493+
make install
410494
411495
- name: Refresh links to shared libs
412496
run: sudo ldconfig ;
@@ -449,6 +533,7 @@ jobs:
449533
fi
450534
451535
- name: Print config.log
536+
shell: bash
452537
run: |
453538
cd build ;
454539
cat config.log ;
@@ -486,6 +571,7 @@ jobs:
486571
if: ${{ matrix.build-type != 'iwyu' }}
487572

488573
- name: Print tests results
574+
shell: bash
489575
run: |
490576
cd build ;
491577
cat test/test-suite.log ;

README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Copyright (C) 2011-2019 Sebastiano Merlino.
1010

1111
# The libhttpserver reference manual
1212
![GA: Build Status](https://github.com/etr/libhttpserver/actions/workflows/verify-build.yml/badge.svg)
13-
[![Build status](https://ci.appveyor.com/api/projects/status/ktoy6ewkrf0q1hw6/branch/master?svg=true)](https://ci.appveyor.com/project/etr/libhttpserver/branch/master)
1413
[![codecov](https://codecov.io/gh/etr/libhttpserver/branch/master/graph/badge.svg)](https://codecov.io/gh/etr/libhttpserver)
1514
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/1bd1e8c21f66400fb70e5a5ce357b525)](https://www.codacy.com/gh/etr/libhttpserver/dashboard?utm_source=github.com&utm_medium=referral&utm_content=etr/libhttpserver&utm_campaign=Badge_Grade)
1615
[![Gitter chat](https://badges.gitter.im/etr/libhttpserver.png)](https://gitter.im/libhttpserver/community)
@@ -119,6 +118,53 @@ Here are listed the libhttpserver specific options (the canonical configure opti
119118

120119
[Back to TOC](#table-of-contents)
121120

121+
### Building on Windows (MSYS2)
122+
123+
MSYS2 provides multiple shell environments with different purposes. Understanding which shell to use is important:
124+
125+
| Shell | Host Triplet | Runtime Dependency | Use Case |
126+
|-------|--------------|-------------------|----------|
127+
| **MinGW64** | `x86_64-w64-mingw32` | Native Windows | **Recommended** for native Windows apps |
128+
| **MSYS** | `x86_64-pc-msys` | msys-2.0.dll | POSIX-style apps, build tools |
129+
130+
**Recommended: Use the MinGW64 shell** for building libhttpserver to produce native Windows binaries without additional runtime dependencies.
131+
132+
#### Step-by-step build instructions
133+
134+
1. Install [MSYS2](https://www.msys2.org/)
135+
136+
2. Open the **MINGW64** shell (not the MSYS shell) from the Start Menu
137+
138+
3. Install dependencies:
139+
```bash
140+
pacman -S --needed mingw-w64-x86_64-{gcc,libtool,make,pkg-config,doxygen,gnutls,curl} autotools
141+
```
142+
143+
4. Build and install [libmicrohttpd](https://www.gnu.org/software/libmicrohttpd/) (>= 0.9.64)
144+
145+
5. Build libhttpserver:
146+
```bash
147+
./bootstrap
148+
mkdir build && cd build
149+
../configure --disable-fastopen
150+
make
151+
make check # run tests
152+
```
153+
154+
**Important:** The `--disable-fastopen` flag is required on Windows as TCP_FASTOPEN is not supported.
155+
156+
#### If you use the MSYS shell
157+
158+
Building from the MSYS shell also works but the resulting binaries will depend on `msys-2.0.dll`. The configure script will display a warning when building in this environment. If you see:
159+
160+
```
161+
configure: WARNING: Building from MSYS environment. Binaries will depend on msys-2.0.dll.
162+
```
163+
164+
Consider switching to the MinGW64 shell for native Windows binaries.
165+
166+
[Back to TOC](#table-of-contents)
167+
122168
## Getting Started
123169
The most basic example of creating a server and handling a requests for the path `/hello`:
124170
```cpp

appveyor.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)