[Spice-devel] [PATCH 4/4 v2] mingw: include <winsock2.h> and link to ws2_32

Fabiano FidĂȘncio fidencio at redhat.com
Thu Oct 8 08:23:28 PDT 2015


Otherwise the following errors can be faced:
src/vscclient-vscclient.o: In function `send_msg':
/home/ffidenci/src/upstream/libcacard/src/vscclient.c:122: undefined
reference to `_imp__htonl at 4'
/home/ffidenci/src/upstream/libcacard/src/vscclient.c:124: undefined
reference to `_imp__htonl at 4'
src/vscclient-vscclient.o: In function `on_host_init':
/home/ffidenci/src/upstream/libcacard/src/vscclient.c:260: undefined
reference to `_imp__ntohl at 4'
/home/ffidenci/src/upstream/libcacard/src/vscclient.c:273: undefined
reference to `_imp__ntohl at 4'
src/vscclient-vscclient.o: In function `do_socket_read':
/home/ffidenci/src/upstream/libcacard/src/vscclient.c:332: undefined
reference to `_imp__ntohl at 4'
/home/ffidenci/src/upstream/libcacard/src/vscclient.c:333: undefined
reference to `_imp__ntohl at 4'
/home/ffidenci/src/upstream/libcacard/src/vscclient.c:334: undefined
reference to `_imp__ntohl at 4'
src/vscclient-vscclient.o: In function `connect_to_qemu':
/home/ffidenci/src/upstream/libcacard/src/vscclient.c:615: undefined
reference to `_imp__socket at 12'
/home/ffidenci/src/upstream/libcacard/src/vscclient.c:628: undefined
reference to `_imp__getaddrinfo at 16'
/home/ffidenci/src/upstream/libcacard/src/vscclient.c:636: undefined
reference to `_imp__connect at 12'
/home/ffidenci/src/upstream/libcacard/src/vscclient.c:645: undefined
reference to `_imp__freeaddrinfo at 4'
/home/ffidenci/src/upstream/libcacard/src/vscclient.c:650: undefined
reference to `_imp__freeaddrinfo at 4'
/home/ffidenci/src/upstream/libcacard/src/vscclient.c:652: undefined
reference to `_imp__closesocket at 4'
src/vscclient-vscclient.o: In function `main':
/home/ffidenci/src/upstream/libcacard/src/vscclient.c:676: undefined
reference to `_imp__WSAStartup at 8'
/home/ffidenci/src/upstream/libcacard/src/vscclient.c:677: undefined
reference to `_imp__WSAGetLastError at 0'
/home/ffidenci/src/upstream/libcacard/src/vscclient.c:778: undefined
reference to `_imp__htonl at 4'
/home/ffidenci/src/upstream/libcacard/src/vscclient.c:791: undefined
reference to `_imp__closesocket at 4'
collect2: error: ld returned 1 exit status
Makefile:656: recipe for target 'vscclient.exe' failed
make[2]: *** [vscclient.exe] Error 1
make[2]: Leaving directory '/home/ffidenci/src/upstream/libcacard'
Makefile:774: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/ffidenci/src/upstream/libcacard'
Makefile:495: recipe for target 'all' failed
make: *** [all] Error 2
---
Changes since v1:
- Fix the host_os check
- Include winsock2 _before_ the ws2tcpip include
---
 Makefile.am     | 4 ++++
 src/vscclient.c | 1 +
 2 files changed, 5 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index f39f5d8..7939079 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -40,6 +40,10 @@ libcacard_la_LDFLAGS =					\
 	$(WARN_LDFLAGS)
 	$(NULL)
 
+if OS_WIN32
+libcacard_la_LIBADD += -lws2_32
+endif
+
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libcacard.pc
 
diff --git a/src/vscclient.c b/src/vscclient.c
index 24015ef..e9fd3aa 100644
--- a/src/vscclient.c
+++ b/src/vscclient.c
@@ -20,6 +20,7 @@
 #include <unistd.h>
 #define closesocket(x) close(x)
 #else
+#include <winsock2.h>
 #include <ws2tcpip.h>
 #include <getopt.h>
 #endif
-- 
2.4.3



More information about the Spice-devel mailing list