【问题标题】:No such file or directory when installing wirelatency安装wirelatency时没有这样的文件或目录
【发布时间】:2020-08-18 00:23:46
【问题描述】:

我尝试在装有 Windows 操作系统的 PC 中安装 wirelatency。当我尝试运行 go install protocol-observer.go 时,出现以下错误:

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.

如何安装它? 欲了解更多信息,我所在位置的大部分谷歌服务都被屏蔽了。

【问题讨论】:

  • 你安装了libpcap吗?
  • 这个 Go 包显然使用cgolibpcap 交互。我推测您缺少 libpcap 的“开发文件”——包括所谓的“头文件”(*.h),其中包含库操作的数据类型和函数的定义。请注意,您还需要适用于 Windows 的 GCC 兼容 C 编译器,例如 TDM-GCCMinGW
  • @JimB 我之前为 windows 安装了winpcap,wireshark 在我的电脑上运行。
  • 我不太明白你这样做有什么困难。 1)检查头文件是否存在,进入安装包创建的目录,查看是否有这些文件; 2)您必须确保编译器能够“看到”这些文件。有不同的方法可以做到这一点——要么确保包含这些文件的目录列在包含文件的“标准”路径列表中,要么让编译器使用附加路径(通过CFLAGS 环境变量);有关更多详细信息,请参阅cgo 文档(见上文)。
  • 请注意 go installing 文件是 Platin 错误。

标签: go


【解决方案1】:

似乎您需要 PCAP 标头来构建它,因为它使用 CGO 作为其依赖项之一。在 GitHub 中获得了关于这个问题的 issue,以及在 Stack Overflow 中的 question 关于编译这种无线延迟的依赖关系。

您还可以克隆存储库并更新依赖项,如 recent versions of gopacket doesn't need CGO anymore

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-06
    • 2018-02-15
    • 1970-01-01
    相关资源
    最近更新 更多