Я смог скомпилировать это, переместив папки SDK из C:\WdpPack
в мою папку C:\User
. Я не очень знаком с Windows, поэтому я не уверен, почему это работает, может быть, что-то делать с разрешениями?
Обновление :
После запуска perl Makefile.PL
, выполнение gmake
для компиляции модуля завершается ошибкой:
[...]
stubs.inc:91:8: error: redefinition of 'struct pcap_if'
[...]
stubs.inc:267:5: error: conflicting types for 'pcap_compile_nopcap'
[...]
stubs.inc:357:8: error: redefinition of 'struct pcap_rmtauth'
[...]
stubs.inc:363:10: error: conflicting types for 'pcap_open'
[...]
stubs.inc:438:8: error: redefinition of 'struct pcap_send_queue'
[...]
stubs.inc:497:8: error: redefinition of 'struct pcap_samp'
Исправить это отредактируйте файл stubs.inc
:
удалите строки 91-97
struct pcap_if {
struct pcap_if *next;
char *name; /* name to hand to "pcap_open_live()" */
char *description; /* textual description of interface, or NULL */
struct pcap_addr *addresses;
bpf_u_int32 flags; /* PCAP_IF_ interface flags */
};
удалите строки: 267-271
int pcap_compile_nopcap(int snaplen, int linktype, struct bpf_program *fp, char *str, int optimize, bpf_u_int32 netmask);
int pcap_compile_nopcap(int snaplen, int linktype, struct bpf_program *fp, char *str, int optimize, bpf_u_int32 netmask) {
FUNCTION_NOT_IMPLEMENTED_ERROR(pcap_compile_nopcap)
return -1;
удалить строки: 357-361
struct pcap_rmtauth {
int type;
char *username;
char *password;
};
удалить строки 438-442:
struct pcap_send_queue{
u_int maxlen;
u_int len;
char *buffer;
};
удалить строки 519-521:
struct pcap_samp {
int method;
int value;
};
Теперь gmake
компилирует файлы, но компоновщик не работает:
[...]
C:/Strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: Pcap.o:Pcap.c:(.text+0x23be): undefined reference to `pcap_geterr'
C:/Strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: Pcap.o:Pcap.c:(.text+0x2580): undefined reference to `pcap_geterr'
C:/Strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: Pcap.o:Pcap.c:(.text+0x2590): undefined reference to `pcap_stats'
C:/Strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: Pcap.o:Pcap.c:(.text+0x2820): undefined reference to `pcap_fileno'
C:/Strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: Pcap.o:Pcap.c:(.text+0x29c4): undefined reference to `pcap_file'
[...]
Проблема здесь было то, что мы связались с 32-битной библиотекой wpcap.lib
, см. этот пост. И получается, что в папке Lib/x64
есть 64-битная версия библиотеки в SDK. Таким образом, мы должны повторно запустить Makefile.PL
с правильным путем к библиотеке:
perl Makefile.PL INC=-IC:/Users/Me/Libraries/npcap/Include "LIBS=-LC:/Users/Me/Libraries/npcap/Lib/x64 -lwpcap"
(измените пути в приведенной выше команде, чтобы они соответствовали каталогу установки для SDK), а затем повторно запустите gmake
.