# How to compile packetbeat from source on a linux distribution where the libpcap library is installed in the custom location

**URL:** https://discuss.elastic.co/t/how-to-compile-packetbeat-from-source-on-a-linux-distribution-where-the-libpcap-library-is-installed-in-the-custom-location/77463
**Category:** Beats
**Tags:** packetbeat
**Created:** [March 6, 2017, 9:06am UTC](https://discuss.elastic.co/t/how-to-compile-packetbeat-from-source-on-a-linux-distribution-where-the-libpcap-library-is-installed-in-the-custom-location/77463 "2017-03-06T09:06:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Dibyendu\_Das](https://avatars.discourse-cdn.com/v4/letter/d/e19b73/32.png) [@Dibyendu\_Das](https://discuss.elastic.co/u/Dibyendu_Das)
#### Post date: [March 6, 2017, 9:06am UTC](https://discuss.elastic.co/t/how-to-compile-packetbeat-from-source-on-a-linux-distribution-where-the-libpcap-library-is-installed-in-the-custom-location/77463/1 "2017-03-06T09:06:35Z")

</div>

Hi, I'm trying to build packet-beat from source following the guide [here](https://github.com/elastic/beats/blob/master/CONTRIBUTING.md#setting-up-your-dev-environment). I'm using a 64bit linux distribution where the `libpcap` library is installed in a different location than its default path i.e `/usr/local/lib`. How to compile packet-beat using this libpcap ?

---

<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: [March 9, 2017, 9:56pm UTC](https://discuss.elastic.co/t/how-to-compile-packetbeat-from-source-on-a-linux-distribution-where-the-libpcap-library-is-installed-in-the-custom-location/77463/2 "2017-03-09T21:56:59Z")

</div>

You need to set the include path using CFLAGS. You can modify the [source file](https://github.com/elastic/beats/blob/master/vendor/github.com/tsg/gopacket/pcap/pcap.go#L11) to add your custom include path or you can use an env var to pass the info to the compiler.

`export CGO_CFLAGS="-I/my/custom/path"`

See [https://golang.org/cmd/cgo/](https://golang.org/cmd/cgo/) for more info about CFLAGS and Go.

---

<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: [April 6, 2017, 9:56pm UTC](https://discuss.elastic.co/t/how-to-compile-packetbeat-from-source-on-a-linux-distribution-where-the-libpcap-library-is-installed-in-the-custom-location/77463/3 "2017-04-06T21:56:59Z")

</div>

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