Skip to content

Commit 478efb9

Browse files
committed
win: update build advice for win11
1 parent 6a2542d commit 478efb9

File tree

3 files changed

+33
-80
lines changed

3 files changed

+33
-80
lines changed

.sai.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@
2323
"netbsd/aarch64BE-bcm2837-a53/gcc": {
2424
"build": "mkdir build destdir;cd build;export LD_LIBRARY_PATH=../destdir/usr/local/share/libwebsockets-test-server/plugins:../destdir/usr/local/lib;export CCACHE_DISABLE=1;cmake .. ${cmake};make -j6 && rm -rf ../destdir && make -j6 DESTDIR=../destdir install && /usr/pkg/bin/ctest -j3 --output-on-failure",
2525
"default": false
26-
}
26+
},
27+
"w11/x86_64-amd/msvc": {
28+
"build": "mkdir build && cd build && set SAI_CPACK=\"-G ZIP\" && cmake .. -DOPENSSL_ROOT_DIR=\"C:\\Users\\andy\\vcpkg\\packages\\openssl_x64-windows\" -DLWS_EXT_PTHREAD_INCLUDE_DIR=\"C:\\Program Files (x86)\\pthreads\\include\" -DLWS_EXT_PTHREAD_LIBRARIES=\"C:\\Program Files (x86)\\pthreads\\lib\\x64\\libpthreadGC2.a\" ${cmake} && cmake --build . --config DEBUG && set CTEST_OUTPUT_ON_FAILURE=1 && ctest . -C DEBUG -j1 --output-on-failure",
29+
"default": false
30+
}
2731
},
2832
"configurations": {
2933
"default": {
3034
"cmake": "",
31-
"platforms": "netbsd/aarch64BE-bcm2837-a53/gcc"
35+
"platforms": "w11//x86_64-amd/msvc,netbsd/aarch64BE-bcm2837-a53/gcc"
3236
},
3337
"default-noudp": {
3438
"cmake": "-DLWS_WITH_UDP=0"
@@ -74,7 +78,7 @@
7478
},
7579
"secure-streams": {
7680
"cmake": "-DLWS_WITH_SECURE_STREAMS=1 -DLWS_WITH_MINIMAL_EXAMPLES=1",
77-
"platforms": "netbsd/aarch64BE-bcm2837-a53/gcc"
81+
"platforms": "w11/x86_64-amd/msvc,netbsd/aarch64BE-bcm2837-a53/gcc"
7882
},
7983
"secure-streams-proxy": {
8084
"cmake": "-DLWS_WITH_SECURE_STREAMS=1 -DLWS_WITH_SECURE_STREAMS_PROXY_API=1 -DLWS_WITH_MINIMAL_EXAMPLES=1 -DLWS_WITH_SECURE_STREAMS_AUTH_SIGV4=1"
@@ -149,7 +153,8 @@
149153
"cmake": "-DLWS_WITH_CGI=ON"
150154
},
151155
"nologs": {
152-
"cmake": "-DLWS_WITH_NO_LOGS=ON"
156+
"cmake": "-DLWS_WITH_NO_LOGS=ON",
157+
"platforms": "w11/x86_64-amd/msvc"
153158
},
154159
"cookiejar": {
155160
"cmake": "-DLWS_WITH_CACHE_NSCOOKIEJAR=ON"

READMEs/README.build-windows.md

Lines changed: 23 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Some notes for the windows jungle
22

33
This was how I compiled libwebsockets starting from a blank windows install
4-
in March - April 2020. Doing this on a linux distro is way simpler and quicker
4+
in June 2025. Doing this on a linux distro is way simpler and quicker
55
than all this!
66

77
## Notes on vm installation
@@ -17,7 +17,9 @@ the windows it came with, you can recover your 'windows tax' windows product key
1717
from your device typically using `sudo strings /sys/firmware/acpi/tables/MSDM`,
1818
and use that for your VM install.
1919

20-
### Required: Spice guest
20+
### Required: Spice guest
21+
22+
Note: I wasn't able to get this to work on Windows 11
2123

2224
To have shared clipboard, and for windows video driver to match your vm window
2325
resolution, you must install spice guest tools inside the windows VM. It also
@@ -34,6 +36,8 @@ bar prediction
3436

3537
### Blood-pressure reduction: Clink
3638

39+
Note: I wasn't able to get this to work on Windows 11.
40+
3741
This is a hack on cmd.exe that lets it understand Ctrl-R and fixup unix-style
3842
slashes automagically.
3943

@@ -77,76 +81,25 @@ the other FOSS projects.
7781

7882
### Required: OpenSSL
7983

80-
Ugh... I tried using prebuilts but it's unreliable and needs an unfeasible
81-
amount of trust. So I recommend bite the bullet and build your own... that's
82-
trivial on Linux but of course windows makes everything nasty.
83-
84-
At least hopefully all the "research" is done and listed out here.
85-
86-
#### OpenSSL build Prerequisite: install perl binary
87-
88-
Move the git version of perl out of the way, it won't work for OpenSSL build
84+
Since I last did this, vcpkg has essentially wrapped the complicated build process.
8985

9086
```
91-
mv /usr/bin/perl /usr/bin/perl-git
87+
> git clone https://github.com/microsoft/vcpkg
88+
> vcpkg integrate install
89+
> vcpkg install openssl:x64-windows
9290
```
9391

94-
For windows, OpenSSL "recommends" ActiveState perl but it doesn't work for me,
95-
complaining about stuff needed from cpan and then dying when it was installed.
96-
"Strawberry Perl" is installed in `C:\Strawberry` and worked out the box.
97-
98-
http://strawberryperl.com/download/5.30.2.1/strawberry-perl-5.30.2.1-64bit.msi
99-
100-
The installer sets up `%PATH%` if you open a new cmd window.
101-
102-
#### OpenSSL build Prerequisite: NASM
92+
It took 30 minutes to build the thing apparently in the same way that was previously
93+
described here manually.
10394

104-
Go here and click on the latest stable, download the win32 .exe
95+
### Powershell
10596

106-
https://nasm.us/
107-
108-
Just install via the defaults. Then add it to the PATH temporarily...
97+
CMake wants it and the version that comes with windows is too old to have pwsh.exe.
10998

11099
```
111-
$ set PATH=%PATH%;C:\Program Files (x86)\NASM
100+
> sudo winget install --id Microsoft.PowerShell --source winget
112101
```
113102

114-
#### OpenSSL build setup: source VC env vars
115-
116-
These fix up the PATH and include dirs etc necessary for VC build in the cmd
117-
window.
118-
119-
```
120-
$ call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
121-
```
122-
123-
### OpenSSL build:
124-
125-
Grab openssl from git... assuming the prerequisites above went well it will
126-
just sit there building for 30 minutes or whatever.
127-
128-
```
129-
$ git clone https://github.com/openssl/openssl
130-
$ cd openssl
131-
$ perl Configure VC-WIN64A
132-
$ nmake
133-
```
134-
135-
Afterwards, open an Administrator mode cmd.exe, redo the msvc path and then
136-
install the build.
137-
138-
```
139-
$ cd openssl
140-
$ call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
141-
$ nmake install
142-
```
143-
144-
Oh another grindingly slow windows build action. Finally it's in there in
145-
`C:\Program Files\OpenSSL`.
146-
147-
libraries are looking for a cert bundle at "C:\Program Files\Common Files\SSL\cert.pem"...
148-
it's not documented or included in the zip file from the above, so...
149-
150103
#### Installing a cert bundle
151104

152105
You can get a trusted cert bundle from here
@@ -167,12 +120,6 @@ ftp://sourceware.org/pub/pthreads-win32
167120
Then I created a dir "C:\Program Files (x86)\pthreads", and copied the `dll`,
168121
`include` and `lib` subdirs from the `prebuilt` folder in the zip there.
169122

170-
The cmake incantation to build against pthreads set up like that is
171-
172-
```
173-
$ cmake .. -DLWS_HAVE_PTHREAD_H=1 -DLWS_EXT_PTHREAD_INCLUDE_DIR="C:\Program Files (x86)\pthreads\include" -DLWS_EXT_PTHREAD_LIBRARIES="C:\Program Files (x86)\pthreads\lib\x64\libpthreadGC2.a" -DLWS_WITH_MINIMAL_EXAMPLES=1
174-
```
175-
176123
## Building libwebsockets
177124

178125
We'll clone libwebsockets then use cmake to build via vs tools
@@ -182,25 +129,26 @@ We'll clone libwebsockets then use cmake to build via vs tools
182129
> cd libwebsockets
183130
> mkdir build
184131
> cd build
185-
> cmake ..
186-
> cmake --build . --config DEBUG
132+
> cmake .. -DLWS_HAVE_PTHREAD_H=1 -DLWS_EXT_PTHREAD_INCLUDE_DIR="C:\Program Files (x86)\pthreads\include" -DLWS_EXT_PTHREAD_LIBRARIES="C:\Program Files (x86)\pthreads\lib\x64\libpthreadGC2.a" -DOPENSSL_ROOT_DIR="c:\Users\<user>\vcpkg\packages\openssl_x64-windows"
133+
> cmake --build . -j 4 --config DEBUG
187134
```
188135

189-
Installing requires admin privs, I opened a second cmd window as admin and did it
190-
there.
136+
Installing:
191137

192138
```
193-
> cmake --install . --config DEBUG
139+
> sudo cmake --install . --config DEBUG
194140
```
195141

196142
### Hack the libs into view
197143

198144
The libs we built against aren't visible in the system, I don't know what
199-
Real Windows Programmers are supposed to do about that, but I used an Admin cmd
145+
Real Windows Programmers are supposed to do about that, but I used sudo
200146
prompt to copy them into C:\windows\system32
201147

202148
```
203-
$ cp "C:\Program Files (x86)\pthreads\dll\x64\pthreadGC2.dll" "C:\Program Files\OpenSSL\bin\libcrypto-3.dll" "C:\Program Files\OpenSSL\bin\libssl-3.dll" C:\Windows\system32
149+
> sudo copy "C:\Program Files (x86)\pthreads\dll\x64\pthreadGC2.dll" C:\Windows\system32
150+
> sudo copy "c:\Users\<user>\vcpkg\packages\openssl_x64-windows\bin\libcrypto-3.dll" C:\Windows\system32
151+
> sudo copy "c:\Users\<user>\vcpkg\packages\openssl_x64-windows\bin\libssl-3.dll" C:\Windows\system32
204152
```
205153

206154
After that you can run the test apps OK, eg

lib/plat/windows/windows-spawn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,5 +579,5 @@ lws_spawn_get_fd_stdxxx(struct lws_spawn_piped *lsp, int std_idx)
579579
{
580580
assert(std_idx >= 0 && std_idx < 3);
581581

582-
return lsp->pipe_fds[std_idx][!!(n == 0)];
582+
return lsp->pipe_fds[std_idx][!!(std_idx == 0)];
583583
}

0 commit comments

Comments
 (0)