Use ws2_32.dll (Winsock 2) instead of the ancient wsock32.dll (Winsock 1.1)
|Reported by:||justinian||Owned by:|
|Keywords:||winsock winsock2 pragma linking||Cc:|
I've been encountering a problem when using wxWidgets-2.9.5 with boost::asio (or, conceivably, other networking libraries) when relying on calls that differ between winsock 1.1 and winsock 2. (setsockopt with IP_TTL is an example.)
The problem exists even if I exclude networking classes from wx with wxNO_NET_LIB, or wxUSE_SOCKETS=0, have the correct header order and/or never include a wx header that includes <winsock.h>.
#pragma comment(lib, "wsock32")
This causes the winsock 1.1 libraries to be linked, and so calls made to matching functions from winsock 2 link against the wrong functions.
My basic fix for this is to just move the pragma inside the existing ifdef block for wxNO_NET_LIB, which I've attached a simple patch for. Ideally, I'd love to see wx switch to winsock 2 in general as well (winsock 1.1 is 17 years old on the desktop, 10 years old on WinCE..), but I understand that means changing includes and re-testing all the existing classes for compatibility.
Also, I've seen other winsock-related issues here (In particular #10931), which relate to header inclusion order get closed as invalid. Please note that this issue is linking-related, not windows header related.
Change History (8)
Changed 10 months ago by justinian
comment:6 Changed 10 months ago by vadz
- Milestone changed from 3.0 to 3.2
- Summary changed from Auto-linking wsock32 (Winsock 1.1) on MSW causes problems to Use ws2_32.dll (Winsock 2) instead of the ancient wsock32.dll (Winsock 1.1)