[Libwebsockets] libwebsocket build with Msys2 and MinGW64

Andy Green andy at warmcat.com
Fri Dec 1 04:57:02 CET 2017



On 11/30/2017 04:31 PM, Ralph Lessmann wrote:
> Hello,
> 
> 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?

Thanks, I pushed these things on master.

> ·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)
> endif()

Some people still want to build on WINCE and such... I added this but I 
put it inside the MINGW conditional.

> ·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>
> 
> #else
> 
> #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
> 
> +#endif
> 
> +
> 
> #define poll(fdArray, fds, timeout)  WSAPoll((LPWSAPOLLFD)(fdArray), 
> (ULONG)(fds), (INT)(timeout))
> 
> #endif
> 
> I actual don’t know if you will like these small changes, but maybe you 
> can add it to the project.

Sure.  I am looking for someone to help test and maintain the windows 
port.  If you or anyone else is interested, drop me a mail.

-Andy

> Thanks in advance
> 
> Ralph L
> 
> 
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets
> 


More information about the Libwebsockets mailing list