Skip to content

Commit c758fd7

Browse files
committedApr 8, 2015
Link against shlwapi.lib and unify linker input sources for Windows
1 parent d2fc98e commit c758fd7

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed
 

Diff for: ‎src/CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,10 @@ if(WIN32)
195195
# Surpress some useless warnings
196196
add_definitions ( /D "_CRT_SECURE_NO_DEPRECATE" /W1 )
197197
else() # Probably MinGW = GCC
198-
set(PLATFORM_LIBS ws2_32.lib)
198+
set(PLATFORM_LIBS "")
199199
endif()
200+
set(PLATFORM_LIBS ws2_32.lib shlwapi.lib ${PLATFORM_LIBS})
201+
200202
# Zlib stuff
201203
set(ZLIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../zlib/zlib-1.2.5"
202204
CACHE PATH "Zlib include directory")

Diff for: ‎src/socket.cpp

+5-8
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
4444
#include <windows.h>
4545
#include <winsock2.h>
4646
#include <ws2tcpip.h>
47-
#ifdef _MSC_VER
48-
#pragma comment(lib, "ws2_32.lib")
49-
#endif
5047
typedef SOCKET socket_t;
5148
typedef int socklen_t;
5249
#else
@@ -154,7 +151,7 @@ void Address::Resolve(const char *name)
154151

155152
struct addrinfo *resolved, hints;
156153
memset(&hints, 0, sizeof(hints));
157-
154+
158155
// Setup hints
159156
hints.ai_socktype = 0;
160157
hints.ai_protocol = 0;
@@ -168,7 +165,7 @@ void Address::Resolve(const char *name)
168165
{
169166
hints.ai_family = AF_INET;
170167
}
171-
168+
172169
// Do getaddrinfo()
173170
int e = getaddrinfo(name, NULL, &hints, &resolved);
174171
if(e != 0)
@@ -514,7 +511,7 @@ int UDPSocket::Receive(Address & sender, void *data, int size)
514511
dstream << (int) m_handle << " <- ";
515512
sender.print(&dstream);
516513
dstream << ", size=" << received;
517-
514+
518515
// Print packet contents
519516
dstream << ", data=";
520517
for(int i = 0; i < received && i < 20; i++) {
@@ -525,7 +522,7 @@ int UDPSocket::Receive(Address & sender, void *data, int size)
525522
}
526523
if(received > 20)
527524
dstream << "...";
528-
525+
529526
dstream << std::endl;
530527
}
531528

@@ -586,7 +583,7 @@ bool UDPSocket::WaitData(int timeout_ms)
586583
// No data
587584
return false;
588585
}
589-
586+
590587
// There is data
591588
return true;
592589
}

0 commit comments

Comments
 (0)