# Unable to build packetbeat on macOS

**URL:** https://discuss.elastic.co/t/unable-to-build-packetbeat-on-macos/175271
**Category:** Beats
**Created:** [April 3, 2019, 8:27pm UTC](https://discuss.elastic.co/t/unable-to-build-packetbeat-on-macos/175271 "2019-04-03T20:27:58Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mikemadden42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikemadden42/32/71277_2.png) [@mikemadden42](https://discuss.elastic.co/u/mikemadden42)
#### Post date: [April 3, 2019, 8:27pm UTC](https://discuss.elastic.co/t/unable-to-build-packetbeat-on-macos/175271/1 "2019-04-03T20:27:59Z")

</div>

Is anyone else running into issues building packetbeat on macOS? I'm running into the following issue on the master & 7.0 branch.

```bash
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:

```bash
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

```

---

<div class="post-metadata">

### Author: ![mikemadden42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikemadden42/32/71277_2.png) [@mikemadden42](https://discuss.elastic.co/u/mikemadden42)
#### Post date: [April 4, 2019, 2:35pm UTC](https://discuss.elastic.co/t/unable-to-build-packetbeat-on-macos/175271/2 "2019-04-04T14:35:06Z")

</div>

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.

```bash
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

```

```bash
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

```

---

<div class="post-metadata">

### Author: ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)
#### Post date: [April 4, 2019, 4:45pm UTC](https://discuss.elastic.co/t/unable-to-build-packetbeat-on-macos/175271/3 "2019-04-04T16:45:20Z")

</div>

Those branches expect an older version of Go. See the .go-version it the root of the branch.

On master I believe that particular error has been fixed by updating tsg/gopacket in preparation for updating to Go 1.12.

---

<div class="post-metadata">

### Author: ![mikemadden42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikemadden42/32/71277_2.png) [@mikemadden42](https://discuss.elastic.co/u/mikemadden42)
#### Post date: [April 4, 2019, 5:23pm UTC](https://discuss.elastic.co/t/unable-to-build-packetbeat-on-macos/175271/4 "2019-04-04T17:23:20Z")

</div>

Thanks @andrewkroh. You were correct with your statement that I needed older versions of Go.

The following worked fine:

```bash
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

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [May 2, 2019, 7:23pm UTC](https://discuss.elastic.co/t/unable-to-build-packetbeat-on-macos/175271/5 "2019-05-02T19:23:21Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
