Problems with include paths with the cloud particle

Our source tree is similar to the following format

With header and source files in every directory except in the main /src directory which only contains makefiles.
We are unable to use relative paths to indicate the location of header files in our .cpp files, for example:
#include “…/headerfile1.h”

when we use the particle compile cloud command the particle compiler complains: “unable to find file src/proj/headerfile1.h”. I have no idea why it injected another directory into the search path.

We would like to use both the modular particle cloud method of compiling and flashing for updating particle firmware normally and the monolithic local method of compiling and flashing for troubleshooting.

We need to indicate relative header file locations such as “…/headerfile1.h” for monolithic local compilations which causes problems when attempting to use the modular particle cloud method of compilation.

Does anybody know a way with multiple levels of subdirectories to allow both monolithic local compilations and modular cloud compilations without a bunch of #ifs in the code?



Let me see if I can ping someone that might be able to help you with this. @Dave, are you able to assist with this?




That’s a great question! Your project is placed in a temporary folder when it’s built. Checkout the makefile syntax, the cloud compiler is using essentially the same thing as the local build, so if you get your user dir and other variables aligned, it should work as expected:


1 Like

As David said, this is definitely supposed to work so let’s figure out what’s going on.

If you don’t have a file at the root of your firmware (one directory up from src) it might help to create a blank file with that name. If you used libraries in your project those would be added to the

If that doesn’t work, it would help if you could upload a small zip file with a folder structure that fails. Let me know the tool you use (CLI or Desktop IDE) and OS.


I got the relative header paths to work with cloud compile.

My directory structure is like:

In main.cpp I have my include file paths as,

#include “Particle.h”
#include “lib/lib2/lib2.h”
#include “lib/lib1/lib1_1/lib1_1.h”
#include “lib/lib1/lib1.h”
#include “lib/lib.h”

My makefile has particle compile photon src command

In this directory structure, the src(folder with .h and .cpp files) and makefile are at the same level. Also the particle cli appends the directory name between " and the first occurance of ‘/’ in the #include “…” line.

So my include lines pasted above gets converted to:

#include “src/Particle.h”
#include “src/lib/lib2/lib2.h”
#include “src/lib/lib1/lib1_1/lib1_1.h”
#include “src/lib/lib1/lib1.h”
#include “src/lib/lib.h”

If the makefile is in src folder the command would be

particle compile photon …/src

This compiled for both cloud and local builds.

Thank you

1 Like

I have this directory structure where compiling code from multiple directories fail.

Unlink in my previous comment, I can’t compile the entire src folder using particle compile photon src because my src folder now contains tests folder which is not part of the particle code. So I wanted to list the directories for compilation myself.

My main.cpp has these header includes,
#include “Particle.h”
#include “lib/lib2/lib2.h”
#include “lib/lib1/lib1_1/lib1_1.h”
#include “lib/lib1/lib1.h”
#include “lib/lib.h”

The following is the output from particle compile photon lib main.cpp,

attempting to compile firmware
Compile failed. Exiting.
main.cpp:2:27: fatal error: liblib/lib2/lib2.h: No such file or directory
#include “liblib/lib2/lib2.h”

As you can see this is messing up my relative path. How do I get the compilation to work with this structure?

Thank you

Here’s a structure that works:

  • Put your project sources in src
  • Put your tests that should not be cloud compiled in tests (outside of src)
  • Put your makefile in the root
  • Create an empty file at the root. This is important so that the local and cloud compilers know that your sources are in src and that tests should be ignored.

My cloud compile command was:

particle compile photon .

My simple local compilation makefile was:

APPDIR=$(shell pwd)
	cd ~/Programming/firmware/main && \

Here’s the whole structure zipped. You’ll have to update the path to your local firmware to compile.

Let me know if that fixes your compile issues. I’ll mark this thead as solved.