Include external headers/code for application.cpp


I have been following the instructions here 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! :smile:

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. :boom:

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

Hello Kenneth,

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

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

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.

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