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

mdns_cpp: Compile error when building with MSYS2/MINGW. #8

Open
mayd opened this issue Aug 10, 2023 · 0 comments
Open

mdns_cpp: Compile error when building with MSYS2/MINGW. #8

mayd opened this issue Aug 10, 2023 · 0 comments

Comments

@mayd
Copy link

mayd commented Aug 10, 2023

When I try to build mdns_cpp on Windows with MSYS2/MINGW it fails with the following output:

$ cmake --build .
[ 10%] Building CXX object CMakeFiles/mdns_cpp.dir/src/logger.cpp.obj
[ 20%] Building CXX object CMakeFiles/mdns_cpp.dir/src/mdns.cpp.obj
C:\msys64\home\david\projects\mdns_cpp-master\src\mdns.cpp: In member function 'int mdns_cpp::mDNS::openServiceSockets(int*, int)':
C:\msys64\home\david\projects\mdns_cpp-master\src\mdns.cpp:38:26: error: 'in4addr_any' was not declared in this scope; did you mean 'in6addr_any'?
   38 |     sock_addr.sin_addr = in4addr_any;
      |                          ^~~~~~~~~~~
      |                          in6addr_any
mingw32-make[2]: *** [CMakeFiles\mdns_cpp.dir\build.make:91: CMakeFiles/mdns_cpp.dir/src/mdns.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:88: CMakeFiles/mdns_cpp.dir/all] Error 2
mingw32-make: *** [Makefile:135: all] Error 2

The following patch removed the error and the mdns_cpp build succeeded. And the example programs seem to work as expected.

--- mdns.cpp.original 2022-09-07 14:22:48.000000000 +0800
+++ mdns.cpp  2023-08-10 21:23:03.502663800 +0800
@@ -35,7 +35,7 @@
     sockaddr_in sock_addr{};
     sock_addr.sin_family = AF_INET;
 #ifdef _WIN32
-    sock_addr.sin_addr = in4addr_any;
+    sock_addr.sin_addr.s_addr = INADDR_ANY;
 #else
     sock_addr.sin_addr.s_addr = INADDR_ANY;
 #endif
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

1 participant