-2

I try to install wirelatency in my PC with windows OS. When I try to run go install protocol-observer.go I get the following error:

C:\Users\Administrator\go\pkg\mod\github.com\google\gopacket@v1.1.14\pcap\pcap.go:189:7: identifier "_Ctype_struct_bpf_program" may conflict with identifiers generated by cgo
C:\Users\Administrator\go\pkg\mod\github.com\google\gopacket@v1.1.14\pcap\pcap.go:445:13: identifier "_Ctype_struct_pcap_stat" may conflict with identifiers generated by cgo
C:\Users\Administrator\go\pkg\mod\github.com\google\gopacket@v1.1.14\pcap\pcap.go:490:49: identifier "_Ctype_struct_bpf_program" may conflict with identifiers generated by cgo
C:\Users\Administrator\go\pkg\mod\github.com\google\gopacket@v1.1.14\pcap\pcap.go:513:10: identifier "_Ctype_struct_bpf_program" may conflict with identifiers generated by cgo
C:\Users\Administrator\go\pkg\mod\github.com\google\gopacket@v1.1.14\pcap\pcap.go:546:41: identifier "_Ctype_struct_bpf_insn" may conflict with identifiers generated by cgo
C:\Users\Administrator\go\pkg\mod\github.com\google\gopacket@v1.1.14\pcap\pcap.go:618:66: identifier "_Ctype_struct_bpf_program" may conflict with identifiers generated by cgo
C:\Users\Administrator\go\pkg\mod\github.com\google\gopacket@v1.1.14\pcap\pcap.go:631:19: identifier "_Ctype_struct_bpf_insn" may conflict with identifiers generated by cgo
C:\Users\Administrator\go\pkg\mod\github.com\google\gopacket@v1.1.14\pcap\pcap.go:741:34: identifier "_Ctype_struct_pcap_addr" may conflict with identifiers generated by cgo
C:\Users\Administrator\go\pkg\mod\github.com\google\gopacket@v1.1.14\pcap\pcap.go:744:56: identifier "_Ctype_struct_pcap_addr" may conflict with identifiers generated by cgo
C:\Users\Administrator\go\pkg\mod\github.com\google\gopacket@v1.1.14\pcap\pcap.go:22:10: fatal error: pcap.h: No such file or directory
 #include <pcap.h>
          ^~~~~~~~
compilation terminated.

How can I install it? For more information most of google services are blocked in my location.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Majid Hajibaba
  • 3,105
  • 6
  • 23
  • 55
  • Have you installed libpcap? – JimB Aug 17 '20 at 15:22
  • This Go package apparently uses [`cgo`](https://golang.org/cmd/cgo/) to interface with [`libpcap`](https://github.com/the-tcpdump-group/libpcap). I would speculate that you're missing the "development files" of libpcap—including the so-called "header files" (`*.h`) which contain definitions of data types and functions operated on by the library. Note that you will also need a GCC-compatible C compiler for Windows—such as [TDM-GCC](https://jmeubank.github.io/tdm-gcc/) or [MinGW](http://www.mingw.org/). – kostix Aug 17 '20 at 15:25
  • @JimB I installed `winpcap` for windows before and wireshark is working in my pc. – Majid Hajibaba Aug 17 '20 at 15:26
  • @kostix I installed MinGW before! But how I can ensure the header files exists while I'm installed winpcap. – Majid Hajibaba Aug 17 '20 at 15:27
  • 1
    I don't quite unserstand what is your difficulty doing this. 1) To check whether header file exist, you go to the directories created by the insallation package and see whether these files are there; 2) You have to make sure the compiler is able to "see" these files. There are different ways to do that—either make sure the directory with these files is listed in the list of "standard" paths for include files, or make the compiler use the additional path (via the `CFLAGS` environment variable); refer to the `cgo` docs for more details (see above). – kostix Aug 17 '20 at 15:39
  • 2
    Note that `go install`ing a file is Platin wrong. – Volker Aug 17 '20 at 18:10

1 Answers1

2

Seems like you need PCAP headers to build it, as it uses CGO for one of it's dependencies. Got a issue in GitHub regarding this very problem, as well as a question here in Stack Overflow about compiling this dependency of wirelatency.

You could also clone the repository and update the dependencies, as recent versions of gopacket doesn't need CGO anymore.

Gustavo Kawamoto
  • 2,665
  • 18
  • 27