Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specific commit broke Windows build #3048

Closed
lesleyrs opened this issue Jan 12, 2024 · 6 comments
Closed

Specific commit broke Windows build #3048

lesleyrs opened this issue Jan 12, 2024 · 6 comments

Comments

@lesleyrs
Copy link

4af9886

I'm unable to build on Windows after this commit (specifically using mingw I get here from https://github.com/skeeto/w64devkit)

The error is related to wol.c inet_aton not being found and some other errors, I don't know enough to help but just leaving this here.

@lws-team
Copy link
Member

Thanks... can you paste the errors?

@lesleyrs
Copy link
Author

libwebsockets\lib\core-net\wol.c: In function 'lws_wol':
libwebsockets\lib\core-net\wol.c:60:14: error: implicit declaration of function 'inet_aton'; did you mean 'inet_pton'? [-Werror=implicit-function-declaration]
   60 |         if (!inet_aton(ip_or_NULL ? ip_or_NULL : "255.255.255.255",
      |              ^~~~~~~~~
      |              inet_pton
libwebsockets\lib\core-net\wol.c:71:24: error: pointer targets in passing argument 2 of 'sendto' differ in signedness [-Werror=pointer-sign]
   71 |         if (sendto(fd, pkt, sizeof(pkt), 0, (struct sockaddr *)&addr,
      |                        ^~~
      |                        |
      |                        uint8_t * {aka unsigned char *}
In file included from libwebsockets/lib/plat/windows/private-lib-plat-windows.h:57,
                 from libwebsockets/lib/core/private-lib-core.h:131,
                 from libwebsockets\lib\core-net\wol.c:25:
w64devkit-1.20.0/w64devkit/x86_64-w64-mingw32/include/winsock2.h:1034:62: note: expected 'const char *' but argument is of type 'uint8_t *' {aka 'unsigned char *'}
 1034 |   WINSOCK_API_LINKAGE int WSAAPI sendto(SOCKET s,const char *buf,int len,int flags,const struct sockaddr *to,int tolen);

@lws-team
Copy link
Member

Does this help?

diff --git a/lib/core-net/wol.c b/lib/core-net/wol.c
index ae0b0373..8edada90 100644
--- a/lib/core-net/wol.c
+++ b/lib/core-net/wol.c
@@ -57,9 +57,9 @@ lws_wol(struct lws_context *ctx, const char *ip_or_NULL, uint8_t *mac_6_bytes)
         addr.sin_family = AF_INET;
         addr.sin_port   = htons(9);
 
-        if (!inet_aton(ip_or_NULL ? ip_or_NULL : "255.255.255.255",
-                        &addr.sin_addr)) {
-                lwsl_cx_err(ctx, "failed to convert broadcast ads, errno %d\n",
+       if (!inet_pton(AF_INET, ip_or_NULL ? ip_or_NULL : "255.255.255.255",
+                                     &addr.sin_addr)) {
+                lwsl_cx_err(ctx, "failed to convert to ipv4 broadcast ads, errno %d\n",
                                  errno);
                 goto bail;
         }
@@ -68,7 +68,8 @@ lws_wol(struct lws_context *ctx, const char *ip_or_NULL, uint8_t *mac_6_bytes)
                 mac_6_bytes[0], mac_6_bytes[1], mac_6_bytes[2], mac_6_bytes[3],
                 mac_6_bytes[4], mac_6_bytes[5], ip_or_NULL ? ip_or_NULL : "");
 
-        if (sendto(fd, pkt, sizeof(pkt), 0, (struct sockaddr *)&addr,
+       /* arg2 is normally const void *, on mingw it's const char * */
+        if (sendto(fd, (const char *)pkt, sizeof(pkt), 0, (struct sockaddr *)&addr,
                         sizeof(addr)) < 0) {
                 lwsl_cx_err(ctx, "failed to sendto broadcast ads, errno %d\n",
                                  errno);

@lesleyrs
Copy link
Author

Yes just the example fails now:

libwebsockets\minimal-examples-lowlevel\raw\minimal-raw-wol\minimal-raw-wol.c:13:10: fatal error: net/if.h: No such file or directory
   13 | #include <net/if.h>

lws-team added a commit that referenced this issue Jan 13, 2024
@lws-team
Copy link
Member

I added a patch on main which has the first patch, and should solve the net/if.h thing as well.

@lesleyrs
Copy link
Author

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants