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

building with mingw32 g++ on Windows 10 #67

Open
quan787 opened this issue Mar 21, 2022 · 2 comments
Open

building with mingw32 g++ on Windows 10 #67

quan787 opened this issue Mar 21, 2022 · 2 comments
Milestone

Comments

@quan787
Copy link

quan787 commented Mar 21, 2022

C:\For_CMake\source\sockpp-0.7.1\src\inet_address.cpp: In member function 'std::__cxx11::string sockpp::inet_address::to_string() const':
C:\For_CMake\source\sockpp-0.7.1\src\inet_address.cpp:107:13: error: 'inet_ntop' was not declared in this scope
  auto str = inet_ntop(AF_INET, (void*) &(addr_.sin_addr), buf, INET_ADDRSTRLEN);
             ^~~~~~~~~
C:\For_CMake\source\sockpp-0.7.1\src\inet_address.cpp:107:13: note: suggested alternative: 'inet_ntoa'
  auto str = inet_ntop(AF_INET, (void*) &(addr_.sin_addr), buf, INET_ADDRSTRLEN);
             ^~~~~~~~~
             inet_ntoa
C:\For_CMake\source\sockpp-0.7.1\src\inet_address.cpp: In function 'std::ostream& sockpp::operator<<(std::ostream&, const sockpp::inet_address&)':
C:\For_CMake\source\sockpp-0.7.1\src\inet_address.cpp:117:13: error: 'inet_ntop' was not declared in this scope
  auto str = inet_ntop(AF_INET, (void*) &(addr.sockaddr_in_ptr()->sin_addr),
             ^~~~~~~~~
C:\For_CMake\source\sockpp-0.7.1\src\inet_address.cpp:117:13: note: suggested alternative: 'inet_ntoa'
  auto str = inet_ntop(AF_INET, (void*) &(addr.sockaddr_in_ptr()->sin_addr),
             ^~~~~~~~~
             inet_ntoa
mingw32-make[2]: *** [src\CMakeFiles\sockpp-objs.dir\build.make:138: src/CMakeFiles/sockpp-objs.dir/inet_address.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:141: src/CMakeFiles/sockpp-objs.dir/all] Error 2
mingw32-make: *** [Makefile:148: all] Error 2
@Royalphax
Copy link

Royalphax commented Jun 14, 2022

Hello, I have the same issue,
And from what I understood, inet_ntop is not found in ws2tcpip.h because defined preprocessor _WIN32_WINNT variable is not >= 0x0600
Mine is 0x0502 and for now I don't know how to modify/update it.

EDIT 1 : The weird thing is that on other of my computers, _WIN32_WINNT is well defined and I don't have this issue.
EDIT 2 : MinGW appears to be the responsible for too low _WIN32_WINNT variable. But I don't know yet how to force it to be higher.

Reference : https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170

#define _WIN32_WINNT_NT4                    0x0400 // Windows NT 4.0
#define _WIN32_WINNT_WIN2K                  0x0500 // Windows 2000
#define _WIN32_WINNT_WINXP                  0x0501 // Windows XP
#define _WIN32_WINNT_WS03                   0x0502 // Windows Server 2003
#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

@fpagliughi fpagliughi added this to the v0.8.1 milestone Jan 18, 2023
@fpagliughi fpagliughi modified the milestones: v0.8.1, v0.9 Jan 30, 2023
@fpagliughi
Copy link
Owner

I'm going back over these issues trying to get Windows support as good as I can,

Is this still causing problems?

I'm just trying MinGW for the first time in a long while on Windows 10 with a new install. The library in the develop branch builds and now passes all the unit tests with MSVC and MinGW.

With MinGW, gcc 13.2, it's reporting _WIN32_WINNT as 0x0601, which is Windows 7 (despite this being Win10?)

From an MS web page, it seems to imply that this is supposed to allow you to set the target version of Windows that you want?

https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170

To modify the macros, in a header file (for example, in targetver.h, which is included by some project templates that target Windows), add the following lines.

#define WINVER 0x0A00
#define _WIN32_WINNT 0x0A00

So declare the macros before you include any Windows header(s) and it will honor what you ask? If it can?

Is this something I should add to the library headers, like in platform.h to specify maybe Vista or Win7 as a minimum?
What is the convention for Windows libraries?

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

3 participants