Is anyone else running into issues building packetbeat on macOS? I'm running into the following issue on the master & 7.0 branch.
packetbeat(master): go version
go version go1.12.1 darwin/amd64
packetbeat(master): mage -version
Mage Build Tool v1.8.0-10-g8dce728
Build Date: 2019-04-03T07:22:06-05:00
Commit: 8dce728
built with: go1.12.1
packetbeat(master): mage -v build
Running target: Build
>> build: Building packetbeat
exec: git rev-parse HEAD
Adding build environment vars: map[CGO_ENABLED:1]
exec: go build -o packetbeat -ldflags -X github.com/elastic/beats/libbeat/version.buildTime=2019-04-03T20:22:42Z -X github.com/elastic/beats/libbeat/version.commit=9f3aede8493d9e5d800e1ee45c27be53db50aa9c
# github.com/elastic/beats/vendor/github.com/tsg/gopacket/pcap
../vendor/github.com/tsg/gopacket/pcap/pcap.go:173:7: identifier "_Ctype_struct_bpf_program" may conflict with identifiers generated by cgo
../vendor/github.com/tsg/gopacket/pcap/pcap.go:385:13: identifier "_Ctype_struct_pcap_stat" may conflict with identifiers generated by cgo
../vendor/github.com/tsg/gopacket/pcap/pcap.go:446:10: identifier "_Ctype_struct_bpf_program" may conflict with identifiers generated by cgo
../vendor/github.com/tsg/gopacket/pcap/pcap.go:489:21: identifier "_Ctype_struct_bpf_program" may conflict with identifiers generated by cgo
../vendor/github.com/tsg/gopacket/pcap/pcap.go:552:34: identifier "_Ctype_struct_pcap_addr" may conflict with identifiers generated by cgo
../vendor/github.com/tsg/gopacket/pcap/pcap.go:555:56: identifier "_Ctype_struct_pcap_addr" may conflict with identifiers generated by cgo
../vendor/github.com/tsg/gopacket/pcap/pcap.go:821:13: identifier "_Ctype_struct_pcap_pkthdr" may conflict with identifiers generated by cgo
Error: running "go build -o packetbeat -ldflags -X github.com/elastic/beats/libbeat/version.buildTime=2019-04-03T20:22:42Z -X github.com/elastic/beats/libbeat/version.commit=9f3aede8493d9e5d800e1ee45c27be53db50aa9c" failed with exit code 2
I do not see this issue on the 6.7 or 6.6 branch:
filebeat(6.7): mage -v build
Running target: Build
>> build: Building filebeat
exec: git rev-parse HEAD
Adding build environment vars: map[CGO_ENABLED:1]
exec: go build -o filebeat -ldflags -X github.com/elastic/beats/libbeat/version.buildTime=2019-04-03T20:24:59Z -X github.com/elastic/beats/libbeat/version.commit=f1b55d786066aca600817dc6787d777f446c9dc6
filebeat(6.6): mage -v build
Running target: Build
>> build: Building filebeat
exec: git rev-parse HEAD
Adding build environment vars: map[CGO_ENABLED:1]
exec: go build -o filebeat -ldflags -X github.com/elastic/beats/libbeat/version.buildTime=2019-04-03T20:26:11Z -X github.com/elastic/beats/libbeat/version.commit=cc64201cf64ed2d2e15e168864dca0418085cd73
I just realized that I had built filebeat on the 6.6 & 6.7 branch instead of packetbeat. packetbeat fails to build on these branches.
packetbeat(6.7): mage -v build
2019/04/04 09:32:57 Found Elastic Beats dir at /Users/jimmy/go/src/github.com/elastic/beats
Running target: Build
>> build: Building packetbeat
exec: git rev-parse HEAD
Adding build environment vars: map[CGO_ENABLED:1]
exec: go build -o packetbeat -ldflags -X github.com/elastic/beats/libbeat/version.buildTime=2019-04-04T14:32:57Z -X github.com/elastic/beats/libbeat/version.commit=b7f6e4710f4513ca57ae5cccce6104bba1c64f2d
# github.com/elastic/beats/vendor/github.com/tsg/gopacket/pcap
../vendor/github.com/tsg/gopacket/pcap/pcap.go:173:7: identifier "_Ctype_struct_bpf_program" may conflict with identifiers generated by cgo
../vendor/github.com/tsg/gopacket/pcap/pcap.go:385:13: identifier "_Ctype_struct_pcap_stat" may conflict with identifiers generated by cgo
../vendor/github.com/tsg/gopacket/pcap/pcap.go:446:10: identifier "_Ctype_struct_bpf_program" may conflict with identifiers generated by cgo
../vendor/github.com/tsg/gopacket/pcap/pcap.go:489:21: identifier "_Ctype_struct_bpf_program" may conflict with identifiers generated by cgo
../vendor/github.com/tsg/gopacket/pcap/pcap.go:552:34: identifier "_Ctype_struct_pcap_addr" may conflict with identifiers generated by cgo
../vendor/github.com/tsg/gopacket/pcap/pcap.go:555:56: identifier "_Ctype_struct_pcap_addr" may conflict with identifiers generated by cgo
../vendor/github.com/tsg/gopacket/pcap/pcap.go:821:13: identifier "_Ctype_struct_pcap_pkthdr" may conflict with identifiers generated by cgo
Error: running "go build -o packetbeat -ldflags -X github.com/elastic/beats/libbeat/version.buildTime=2019-04-04T14:32:57Z -X github.com/elastic/beats/libbeat/version.commit=b7f6e4710f4513ca57ae5cccce6104bba1c64f2d" failed with exit code 2
packetbeat(6.6): mage -v build
2019/04/04 09:34:19 Found Elastic Beats dir at /Users/jimmy/go/src/github.com/elastic/beats
Running target: Build
>> build: Building packetbeat
exec: git rev-parse HEAD
Adding build environment vars: map[CGO_ENABLED:1]
exec: go build -o packetbeat -ldflags -X github.com/elastic/beats/libbeat/version.buildTime=2019-04-04T14:34:19Z -X github.com/elastic/beats/libbeat/version.commit=cc64201cf64ed2d2e15e168864dca0418085cd73
# github.com/elastic/beats/vendor/github.com/tsg/gopacket/pcap
../vendor/github.com/tsg/gopacket/pcap/pcap.go:173:7: identifier "_Ctype_struct_bpf_program" may conflict with identifiers generated by cgo
../vendor/github.com/tsg/gopacket/pcap/pcap.go:385:13: identifier "_Ctype_struct_pcap_stat" may conflict with identifiers generated by cgo
../vendor/github.com/tsg/gopacket/pcap/pcap.go:446:10: identifier "_Ctype_struct_bpf_program" may conflict with identifiers generated by cgo
../vendor/github.com/tsg/gopacket/pcap/pcap.go:489:21: identifier "_Ctype_struct_bpf_program" may conflict with identifiers generated by cgo
../vendor/github.com/tsg/gopacket/pcap/pcap.go:552:34: identifier "_Ctype_struct_pcap_addr" may conflict with identifiers generated by cgo
../vendor/github.com/tsg/gopacket/pcap/pcap.go:555:56: identifier "_Ctype_struct_pcap_addr" may conflict with identifiers generated by cgo
../vendor/github.com/tsg/gopacket/pcap/pcap.go:821:13: identifier "_Ctype_struct_pcap_pkthdr" may conflict with identifiers generated by cgo
Error: running "go build -o packetbeat -ldflags -X github.com/elastic/beats/libbeat/version.buildTime=2019-04-04T14:34:19Z -X github.com/elastic/beats/libbeat/version.commit=cc64201cf64ed2d2e15e168864dca0418085cd73" failed with exit code 2
Thanks @andrewkroh. You were correct with your statement that I needed older versions of Go.
The following worked fine:
beats(6.7): cat .go-version
1.10.8
beats(6.7): export PATH="/usr/local/opt/go@1.10/bin:$PATH"
packetbeat(6.7): go version
go version go1.10.8 darwin/amd64
packetbeat(6.7): mage build
2019/04/04 12:22:37 Found Elastic Beats dir at /Users/jimmy/go/src/github.com/elastic/beats
>> build: Building packetbeat
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.