# Include external headers/code for application.cpp

**URL:** <https://community.particle.io/t/include-external-headers-code-for-application-cpp/20495>\
**Category:** Firmware\
**Created:** [February 26, 2016, 3:13pm UTC](https://community.particle.io/t/include-external-headers-code-for-application-cpp/20495 "2016-02-26T15:13:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rclarke](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rclarke/32/9067_2.png) [@rclarke](https://community.particle.io/u/rclarke)\
**Post date:** [February 26, 2016, 3:13pm UTC](https://community.particle.io/t/include-external-headers-code-for-application-cpp/20495/1 "2016-02-26T15:13:10Z")

</div>

Hello!

I have been following the instructions [here](https://github.com/spark/firmware/blob/latest/docs/gettingstarted.md) to get started compiling firmware locally. I have got it to work fine for something basic like the `blink` code which does not require any external libraries, but now I’d like to include the weather shield library.  
I’ve tried putting this in my `application.cpp`

```
#include <SparkFun_Photon_Weather_Shield_Library.h>

```

and setting environment variables:

```
export LIBRARY_PATH=/home/rclarke/repos/SparkFun_Photon_Weather_Shield_Particle_Library/firmware

```

But I still get the error:

```
src/application.cpp:41:52: fatal error: SparkFun_Photon_Weather_Shield_Library.h: No such file or directory

```

So I was wondering, what is the best way to include headers/code from other repositories when compiling firmware without having to copy the files into the `user/src` directory?

Thanks for your help! 😄  
-Robin-

---

<div class="post-metadata">

**Author:** ![kennethlimcp](https://avatars.discourse-cdn.com/v4/letter/k/c0e974/32.png) [@kennethlimcp](https://community.particle.io/u/kennethlimcp)\
**Post date:** [February 26, 2016, 3:34pm UTC](https://community.particle.io/t/include-external-headers-code-for-application-cpp/20495/2 "2016-02-26T15:34:43Z")

</div>

> [@rclarke](#):
>
> export LIBRARY\_PATH=/home/rclarke/repos/SparkFun\_Photon\_Weather\_Shield\_Particle\_Library/firmware

Where is this instruction from?

For local compile, download the `.h and .cpp` files of the library, place it in the root folder of your project and compile. 💥

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [February 26, 2016, 3:37pm UTC](https://community.particle.io/t/include-external-headers-code-for-application-cpp/20495/3 "2016-02-26T15:37:15Z")

</div>

And I’d suggest using `#include "....."` over `#include <....>` for user libs.

---

<div class="post-metadata">

**Author:** ![rclarke](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rclarke/32/9067_2.png) [@rclarke](https://community.particle.io/u/rclarke)\
**Post date:** [February 26, 2016, 3:37pm UTC](https://community.particle.io/t/include-external-headers-code-for-application-cpp/20495/4 "2016-02-26T15:37:27Z")

</div>

Hello Kenneth,

> [@kennethlimcp](#):
>
> > [@rclarke](#):
> >
> > export LIBRARY\_PATH=/home/rclarke/repos/SparkFun\_Photon\_Weather\_Shield\_Particle\_Library/firmware
> 
> Where is this instruction from?

I cobbled that from "I probably failed at googling"...

So there is no way to leave these files elsewhere (so that they can easily be updated by doing a `git pull` in that repository) and still compile the firmware

---

<div class="post-metadata">

**Author:** ![joe4465](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@joe4465](https://community.particle.io/u/joe4465)\
**Post date:** [February 26, 2016, 4:19pm UTC](https://community.particle.io/t/include-external-headers-code-for-application-cpp/20495/5 "2016-02-26T16:19:50Z")

</div>

> [@rclarke](#):
>
> So there is no way to leave these files elsewhere (so that they can easily be updated by doing a git pull in that repository) and still compile the firmware

I would like to know this as well. Copying the files across gets tiresome after a while.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [February 26, 2016, 4:28pm UTC](https://community.particle.io/t/include-external-headers-code-for-application-cpp/20495/6 "2016-02-26T16:28:12Z")

</div>

You can set an `APPDIR` switch to designate an “external” folder as your project folder, and noone is holding you back from cloning the needed libraries into this app folder and including the required files from the `firmware` subfolder of that cloned local git repo.

Another more “esoteric” way could be to use _hard links_ (or even just _symlinks_ or _NTFS junctions_ where possible) to mirror a library into multiple application directories.

---

<div class="post-metadata">

**Author:** ![rclarke](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rclarke/32/9067_2.png) [@rclarke](https://community.particle.io/u/rclarke)\
**Post date:** [February 26, 2016, 7:13pm UTC](https://community.particle.io/t/include-external-headers-code-for-application-cpp/20495/7 "2016-02-26T19:13:11Z")

</div>

Thank you - that’s very helpful! I’m happy now I can keep the actual spark firmware separate from my application code. 😄
