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

cross compile for window on ubuntu error: no TunnelType member in struct IPADAPTER_ADDRESS #569

Closed
anzyelay opened this issue Jul 16, 2020 · 6 comments · Fixed by #574
Closed

Comments

@anzyelay
Copy link

if (adapter->TunnelType == TUNNEL_TYPE_TEREDO)

when i cross compile it ,i found the definitions _WIN32_WINNT means XP, so the struct in iptypes.h pointer to an XP struct which has no member TunnelType.

@anzyelay
Copy link
Author

anzyelay commented Jul 16, 2020

i have resolved it in temporary as follow:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c044fe0..121ad48 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -312,6 +312,7 @@ if(WITH_NETWORK_BACKEND)
                list(APPEND LIBS_TO_LINK ${AVAHI_LIBRARIES})
        elseif(WIN32)
                set(HAVE_DNS_SD ON)
+               set(CMAKE_C_FLAGS "-D_WIN32_WINNT=0x0600 ${CMAKE_C_FLAGS}")
                list(APPEND LIBIIO_CFILES dns_sd_windows.c dns_sd.c)
                if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
                        set_source_files_properties(dns_sd_windows.c PROPERTIES COMPILE_FLAGS "-Wno-unused-function")
diff --git a/mdns.h b/mdns.h
index 58a5bb5..7e164f7 100644
--- a/mdns.h
+++ b/mdns.h
@@ -22,8 +22,8 @@
 
 #include <fcntl.h>
 #ifdef _WIN32
-#include <Winsock2.h>
-#include <Ws2tcpip.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
 #define strncasecmp _strnicmp
 #else
 #include <unistd.h>

@rgetz
Copy link
Contributor

rgetz commented Jul 22, 2020

Thanks for the report.

_WIN32_WINNT should be set by the compiler where _WIN32_WINNT >= 0x600 means one of:

#define _WIN32_WINNT_WIN6                   0x0600 // Windows Vista
#define _WIN32_WINNT_VISTA                  0x0600 // Windows Vista
#define _WIN32_WINNT_WS08                   0x0600 // Windows Server 2008
#define _WIN32_WINNT_LONGHORN               0x0600 // Windows Vista
#define _WIN32_WINNT_WIN7                   0x0601 // Windows 7
#define _WIN32_WINNT_WIN8                   0x0602 // Windows 8
#define _WIN32_WINNT_WINBLUE                0x0603 // Windows 8.1
#define _WIN32_WINNT_WINTHRESHOLD           0x0A00 // Windows 10
#define _WIN32_WINNT_WIN10                  0x0A00 // Windows 10

None of those should mean:

#define _WIN32_WINNT_WINXP                  0x0501 // Windows XP

maybe your cross compiler is set up wrong? Can you describe your build system more?

We build naively with mingw and MSStudio - and have not run into this.

@dNechita
Copy link
Contributor

I have run into this issue when cross compiling iio-oscilloscope on Ubuntu 18.04 for Windows. What I did, was to set _WIN32_WINNT while generating the build system (without changing the CMakefiles.txt content). See here (analogdevicesinc/iio-osc-mingw@5908ee7)

@rgetz
Copy link
Contributor

rgetz commented Jul 23, 2020

MinGW Doc does indicated these need to be set by hand before including windows.h header file. Shouldn't we then just include this in the CMake based on IF(MINGW) ? Cmake Doc

@dNechita
Copy link
Contributor

Yes, I think we should include these definitions when MINGW is used since the dns_sd code for windows won't compile if _WIN32_WINNT points to some old versions of Windows.

rgetz added a commit that referenced this issue Jul 23, 2020
rgetz added a commit that referenced this issue Jul 23, 2020
rgetz added a commit that referenced this issue Jul 23, 2020
rgetz added a commit that referenced this issue Jul 23, 2020
@rgetz
Copy link
Contributor

rgetz commented Jul 23, 2020

I think this is now fixed in #574

@rgetz rgetz closed this as completed Jul 23, 2020
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

Successfully merging a pull request may close this issue.

3 participants