libwebsockets
Lightweight C library for HTML5 websockets
|
This was how I compiled libwebsockets starting from a blank windows install in March - April 2020. Doing this on a linux distro is way simpler and quicker than all this!
For building you'll need 40GB+ available for the guest storage.
Assuming like me the first thing you do with a new laptop is install Linux over the windows it came with, you can recover your 'windows tax' windows product key from your device typically using sudo strings /sys/firmware/acpi/tables/MSDM
, and use that for your VM install.
To have shared clipboard, and for windows video driver to match your vm window resolution, you must install spice guest tools inside the windows VM. It also installs some virtio pieces you will want.
https://www.spice-space.org/download/windows/spice-guest-tools/spice-guest-tools-latest.exe
https://www.mozilla.org/en-US/exp/firefox/
When it's up, add-ons: ublock origin, privacy badger, noscript, disable search bar prediction
This is a hack on cmd.exe that lets it understand Ctrl-R and fixup unix-style slashes automagically.
https://github.com/mridgers/clink/releases/download/0.4.9/clink_0.4.9_setup.exe
If you're usually using *nix, you definitely need this to keep your sanity.
CMake have a windows installer thing downloadable from here
after that you can use cmake
from the terminal OK.
Visit the canonical git site to download their windows installer thing
Select the install option for "extra unix commands" so you can get ls -l
, cp
, mv
and suchlike working in cmd.exe... that's awesome, thanks git!
Afterwards you can just use git
as normal from cmd.exe as well.
You can do this through "windows store" by searching for "visual studio"
I installed as little as possible, we just want the C "C++" tools... 7GB :-)
It still wouldn't link without the "mt" helper tool from the huge windows SDK, so you have to install GB of that as well.
They don't mention it during the install, but after 30 days this "free" "community" edition demands you open a microsoft account or it stops working. In the install they give you the option to add a microsoft account and the alternative is, "not now, maybe later". Compare and contrast to gcc or git or the other FOSS projects.
Ugh... I tried using prebuilts but it's unreliable and needs an unfeasible amount of trust. So I recommend bite the bullet and build your own... that's trivial on Linux but of course windows makes everything nasty.
At least hopefully all the "research" is done and listed out here.
Move the git version of perl out of the way, it won't work for OpenSSL build
For windows, OpenSSL "recommends" ActiveState perl but it doesn't work for me, complaining about stuff needed from cpan and then dying when it was installed. "Strawberry Perl" is installed in C:\Strawberry
and worked out the box.
http://strawberryperl.com/download/5.30.2.1/strawberry-perl-5.30.2.1-64bit.msi
The installer sets up PATH%
if you open a new cmd window.
Go here and click on the latest stable, download the win32 .exe
Just install via the defaults. Then add it to the PATH temporarily...
These fix up the PATH and include dirs etc necessary for VC build in the cmd window.
Grab openssl from git... assuming the prerequisites above went well it will just sit there building for 30 minutes or whatever.
Afterwards, open an Administrator mode cmd.exe, redo the msvc path and then install the build.
Oh another grindingly slow windows build action. Finally it's in there in C:\Program Files\OpenSSL
.
libraries are looking for a cert bundle at "C:\Program Files\Common Files\SSL\cert.pem"... it's not documented or included in the zip file from the above, so...
You can get a trusted cert bundle from here
Save it into C:\Program Files\Common Files\SSL\cert.pem
where openssl will be able to see it.
It's amazing but after all these years windows doesn't offer pthreads compatibility itself. Just like the many other missing POSIX bits like fork().
I downloaded the latest (2012) zip release of pthreads-win32 from here
ftp://sourceware.org/pub/pthreads-win32
Then I created a dir "C:\Program Files (x86)\pthreads", and copied the dll
, include
and lib
subdirs from the prebuilt
folder in the zip there.
The cmake incantation to build against pthreads set up like that is
We'll clone libwebsockets then use cmake to build via vs tools
Installing requires admin privs, I opened a second cmd window as admin and did it there.
The libs we built against aren't visible in the system, I don't know what Real Windows Programmers are supposed to do about that, but I used an Admin cmd prompt to copy them into C:\windows\system32
After that you can run the test apps OK, eg