Stan Huang Ответов: 1

Как разрешить конфликт между WinPcap и Windows kits?


Я начал свою программу с включения:
#define TARGET_SIMU
#include <iostream>
#define INT32_ALREADY_DEFINED

#define _CRT_RAND_S
#include <process.h>
#include <search.h>

#include "iptcom.h"        /* Common type definitions for IPT */
#include "iptcom_priv.h" 

#include "iphlpapi.h"
#define	DATASZ 1000

#include "pcap.h"


У меня есть следующее сообщение об ошибке. Очевидно, что существует конфликт между WinPCap (
C:\Program Files (x86)\WpdPack_4_1_2
) & amp; наборы Windows (
c:\program files (x86)\windows kits\8.1
). WinPCap был загружен с WinPcap * Ресурсы Разработчика[^]
Что я могу сделать, чтобы разрешить этот конфликт?

.............................
1>  Note: including file:     C:\Program Files (x86)\Windows Kits\8.1\Include\shared\ws2def.h
1>c:\program files (x86)\windows kits\8.1\include\shared\ws2def.h(100): warning C4005: 'AF_IPX': macro redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(452): note: see previous definition of 'AF_IPX'
1>c:\program files (x86)\windows kits\8.1\include\shared\ws2def.h(140): warning C4005: 'AF_MAX': macro redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(471): note: see previous definition of 'AF_MAX'
1>c:\program files (x86)\windows kits\8.1\include\shared\ws2def.h(177): warning C4005: 'SO_DONTLINGER': macro redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(394): note: see previous definition of 'SO_DONTLINGER'
1>c:\program files (x86)\windows kits\8.1\include\shared\ws2def.h(221): error C2011: 'sockaddr': 'struct' type redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(1002): note: see declaration of 'sockaddr'
1>c:\program files (x86)\windows kits\8.1\include\shared\ws2def.h(421): error C2059: syntax error: 'constant'
1>c:\program files (x86)\windows kits\8.1\include\shared\ws2def.h(421): error C3805: 'constant': unexpected token, expected either '}' or a ','
1>c:\program files (x86)\windows kits\8.1\include\shared\ws2def.h(556): warning C4005: 'IN_CLASSA': macro redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(279): note: see previous definition of 'IN_CLASSA'
1>c:\program files (x86)\windows kits\8.1\include\shared\ws2def.h(562): warning C4005: 'IN_CLASSB': macro redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(285): note: see previous definition of 'IN_CLASSB'
1>c:\program files (x86)\windows kits\8.1\include\shared\ws2def.h(568): warning C4005: 'IN_CLASSC': macro redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(291): note: see previous definition of 'IN_CLASSC'
1>c:\program files (x86)\windows kits\8.1\include\shared\ws2def.h(579): warning C4005: 'INADDR_ANY': macro redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(296): note: see previous definition of 'INADDR_ANY'
1>c:\program files (x86)\windows kits\8.1\include\shared\ws2def.h(581): warning C4005: 'INADDR_BROADCAST': macro redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(298): note: see previous definition of 'INADDR_BROADCAST'
1>c:\program files (x86)\windows kits\8.1\include\shared\ws2def.h(615): error C2011: 'sockaddr_in': 'struct' type redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(1006): note: see declaration of 'sockaddr_in'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(136): error C2011: 'fd_set': 'struct' type redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(1014): note: see declaration of 'fd_set'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(156): warning C4005: 'FD_CLR': macro redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(89): note: see previous definition of 'FD_CLR'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(171): warning C4005: 'FD_SET': macro redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(94): note: see previous definition of 'FD_SET'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(180): error C2011: 'timeval': 'struct' type redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(1030): note: see declaration of 'timeval'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(236): error C2011: 'hostent': 'struct' type redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(1018): note: see declaration of 'hostent'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(249): error C2011: 'netent': 'struct' type redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(172): note: see declaration of 'netent'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(256): error C2011: 'servent': 'struct' type redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(1022): note: see declaration of 'servent'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(268): error C2011: 'protoent': 'struct' type redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(1026): note: see declaration of 'protoent'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(364): error C2011: 'WSAData': 'struct' type redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(314): note: see declaration of 'WSAData'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(462): error C2011: 'sockproto': 'struct' type redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(486): note: see declaration of 'sockproto'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(504): error C2011: 'linger': 'struct' type redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(1010): note: see declaration of 'linger'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(517): warning C4005: 'SOMAXCONN': macro redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(536): note: see previous definition of 'SOMAXCONN'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(551): warning C4005: 'FD_READ': macro redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(554): note: see previous definition of 'FD_READ'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(554): warning C4005: 'FD_WRITE': macro redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(555): note: see previous definition of 'FD_WRITE'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(557): warning C4005: 'FD_OOB': macro redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(556): note: see previous definition of 'FD_OOB'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(560): warning C4005: 'FD_ACCEPT': macro redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(557): note: see previous definition of 'FD_ACCEPT'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(563): warning C4005: 'FD_CONNECT': macro redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(558): note: see previous definition of 'FD_CONNECT'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(566): warning C4005: 'FD_CLOSE': macro redefinition
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(559): note: see previous definition of 'FD_CLOSE'
1>  Note: including file:     C:\Program Files (x86)\Windows Kits\8.1\Include\shared\qos.h
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(1646): error C2375: 'accept': redefinition; different linkage
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(734): note: see declaration of 'accept'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(1668): error C2375: 'bind': redefinition; different linkage
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(739): note: see declaration of 'bind'
1>c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(1689): error C2375: 'closesocket': redefinition; different linkage
1>  c:\program files (x86)\windows kits\8.1\include\um\winsock.h(744): note: see declaration of 'closesocket'

..........................

Что я уже пробовал:

Я обсуждал это на некоторых форумах и не получил соответствующего ответа.

Richard MacCutchan

Вам нужно выяснить, где находятся предыдущие определения, и удалить этот файл из сборки. Или добавьте какой-нибудь макрос, чтобы включить только один набор.

1 Ответов

Рейтинг:
6

Jochen Arndt

Это проблема не с WinPcap, а с порядком включения заголовочных файлов Windows.

Вы еще не включили окна.ч и в winsock.ч. Таким образом, они включаются, когда это необходимо другим заголовочным файлам. Но вышеупомянутые заголовочные файлы должны быть включены в определенном порядке.

У меня не было вашей установки здесь для тестирования, но включение их сверху должно решить проблему:

// Include winsock2.h before windows.h
#include <winsock2.h>
#include <windows.h>
// Include other header files here

Альтернативное определение WIN32_LEAN_AND_MEAN первый:
// Don't include additional header files from windows.h
// These must be then included explicitly
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
// Include other header files here