Compiling a AssertTracker on CLI

Starting to test my Asset Tracker Set, I have written thisi should program that compiles on Web IDE but doesn’t on CLI.

#include "AssetTracker/AssetTracker.h"

AssetTracker t = AssetTracker();

void setup() {;

void loop() {

Saved as test.cpp, when I run on CLI, I get the error:

C:\Particle\firmware>particle compile electron test.cpp

test.cpp:1:39: fatal error: AssetTracker/AssetTracker.h: No such file or directory
 #include "AssetTracker/AssetTracker.h"
compilation terminated.
make[1]: *** [../build/target/user/platform-10test.o] Error 1
make: *** [user] Error 2

So it can’t fine the header file. I believe that when I compile, the code os sent to the cloud for compilation. How should this header file be added when compiling using CLI.

First, have you downloaded the AssetTracker library? (this link can be found in Web IDE via the GitHub icon next to the lib name, once you selected the lib)
Have you copied the contents of the firmware folder (but not the examples folder) into your project folder?

If so, you need to change your include statement to #include "AssetTracker.h"

In the folder firmware I have AssetTracker.h, AssetTracker.cpp and test.cpp. Here is how it looks

AssetTracker.cpp  AssetTracker.h    examples          test.cpp

And the content of test.cpp is pretty simple:

#include "AssetTracker.h"
void setup() {
void loop() {

Now when I run particle compile electron test.cpp, I get this error

D:\particle\firmware>particle compile electron test.cpp

Compiling code for electron
attempting to compile firmware
Compile failed. Exiting.
test.cpp:1:26: fatal error: AssetTracker.h: No such file or directory
 #include "AssetTracker.h"
compilation terminated.
make[1]: *** [../build/target/user/platform-10test.o] Error 1
make: *** [user] Error 2

But AssetTracker.h is directly in the same folder. So I don’t yet understand how CLI does the compilation. It has even nothing to do with AssetTracker.h. I just created an empty header file test.h and include this in test.cpp file which now look thus:

#include "tests.h"

void setup() {
void loop() {

Still when I compile this I get an error

test.cpp:2:18: fatal error: test.h: No such file or directory:  #include "test.h"

This compiles fine on Web IDE. So the question remains how CLI compiles files. I have the impression that test.cpp is sent to the cloud for compilation and probably there it doesn’t know about the included files. Which seems like the included files must be known at the site where compilation takes place. If I remove the included header it compiles

First try to follow instructions closely!


So remove the examples folder!

And then you need to build the project folder and not only the one source file.

Try this instead

particle compile electron . 

The single dot stands for current directory.

And make sure, you’ve got the most recent CLI (1.15.0) installed.


Thanks!! It works. I now see how it’s setup. So what we call library has to be really put in the application as source file.
That looks good.

For the time being, yes …
… but a new library scheme is just around the corner, so din’t get too used to the “clumsy” solution :sunglasses:

Yes, it’s really a good workaround. We have written codes for AdaFruit FONA 808 module for building a GPS application and are now intending to start with the AssertTracker here.
One more question, I have read that using Serial.println("Test Test test "); will bring to the serial port and this is great during development. Now I have this code
void loop() {
When I compile this and put in the device. When the code is not running on the device connected to a computer with USB where will the output be printed?

What program are you using as serial terminal?
PuTTY is the one I use and should be available on most platforms.
On Windows pre 10, you’d need to install the Particle virtual COM drivers.

I use putty and currently using Windows 7. So I will get Particle virtual COM drivers and install then

1 Like

Hello @ScruffR,

Any updates on that new library source file layout approach you have mentioned (the one you are supposed to use instead pointing to the current directory while compiling)?


If you use Particle Dev, this file describing Libs 2.0 structure is created with a new project…


A Particle project named ProjectName

Welcome to your project!

Every new Particle project is composed of 3 important elements that you’ll see have been created in your project directory for ProjectName.

/src folder:

This is the source folder that contains the firmware files for your project. It should not be renamed.
Anything that is in this folder when you compile your project will be sent to our compile service and compiled into a firmware binary for the Particle device that you have targeted.

If your application contains multiple files, they should all be included in the src folder. If your firmware depends on Particle libraries, those dependencies are specified in the file referenced below.

.ino file:

This file is the firmware that will run as the primary application on your Particle device. It contains a setup() and loop() function, and can be written in Wiring or C/C++. For more information about using the Particle firmware API to create firmware for your Particle device, refer to the Firmware Reference section of the Particle documentation. file:

This is the file that specifies the name and version number of the libraries that your project depends on. Dependencies are added automatically to your file when you add a library to a project using the particle library add command in the CLI or add a library in the Desktop IDE.

Adding additional files to your project

Projects with multiple sources

If you would like add additional files to your application, they should be added to the /src folder. All files in the /src folder will be sent to the Particle Cloud to produce a compiled binary.

Projects with external libraries

If your project includes a library that has not been registered in the Particle libraries system, you should create a new folder named /lib/<libraryname>/src under /<project dir> and add the .h and .cpp files for your library there. All contents of the /lib folder and subfolders will also be sent to the Cloud for compilation.

Compiling your project

When you’re ready to compile your project, make sure you have the correct Particle device target selected and run particle compile <platform> in the CLI or click the Compile button in the Desktop IDE. The following files in your project folder will be sent to the compile service:

  • Everything in the /src folder, including your .ino application file
  • The file for your project
  • Any libraries stored under lib/<libraryname>/src
1 Like

Cool! Thanks.

What is in the Can I get a template of that file without using the Particle Dev?

I would like to move my current CLI-based projects to this new structure.

I don’t intend to use Dev any time soon.


references to Particle libraries e.g.