[Libwebsockets] libwebsocket build with Msys2 and MinGW64

Ralph Lessmann ralph.lessmann at crossmatch.com
Thu Nov 30 09:31:59 CET 2017


I apologize if I'm writing this email to the wrong list, but may I suggest some changes to the libwebsocket project to make it build better with MinGW?

*         I added an explicit windows version to the cmake file

if( WIN32 )
# minimal required target is Windows 7
add_definitions(-DWINVER=0x0601 -D_WIN32_WINNT=0x0601)

*         I also stumbled over compiler errors when building with IP6 support. Strange thing is, it builds fine for WINVER 0x0600, but not for 0x0601.
Somewhere along the lines we may miss an include to wincrypt.h. So I added it. (diff below)

diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c
index 28b967c0..09f5370e 100644
--- a/lib/libwebsockets.c
+++ b/lib/libwebsockets.c
@@ -27,6 +27,7 @@
 #ifdef LWS_WITH_IPV6
#if defined(WIN32) || defined(_WIN32)
+#include <wincrypt.h>
#include <Iphlpapi.h>
#include <net/if.h>

*         Then it failed when building the test server, due to a redefinition of the WINVER. I just added a guard (diff below)

diff --git a/test-apps/test-server.h b/test-apps/test-server.h
index 29e67177..892f1e01 100644
--- a/test-apps/test-server.h
+++ b/test-apps/test-server.h
@@ -19,8 +19,14 @@
 #if defined(_WIN32) && defined(EXTERNAL_POLL)
+#if (WINVER < 0x0600)
+#undef WINVER
+#undef _WIN32_WINNT
#define WINVER 0x0600
-#define _WIN32_WINNT 0x0600
+#define _WIN32_WINNT WINVER
#define poll(fdArray, fds, timeout)  WSAPoll((LPWSAPOLLFD)(fdArray), (ULONG)(fds), (INT)(timeout))

I actual don't know if you will like these small changes, but maybe you can add it to the project.

Thanks in advance

Ralph L

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://libwebsockets.org/pipermail/libwebsockets/attachments/20171130/6df4be39/attachment-0001.html>

More information about the Libwebsockets mailing list