Hi
I’m trying to compile an application using Particle Dev with a directory structure for the libraries.
For example I have the following directory structure
my_spark_app
my_spark_app.ino
libraries
OneWire
OneWire.cpp
OneWire.h
and my my_spark_app.ino
looks like this:
#include "libraries/OneWire/OneWire.h"
void setup() {
}
void loop() {
}
But if I try to compile, it can’t find OneWire.h.
What’s the right way to include the OneWire.h library with the folder structure I have? It can find it if I don’t use any sub folders, but then things get messy.
Thanks
Long ol’ story short - it doesn’t work (yet).
1 Like
Is this still the case? It’s not working for me either.
Is there an expected fix date?
Any further update here? It would be great to be able to use git submodules for library includes.
My current work-around is: https://github.com/edalquist/particle_temp_monitor
At the moment Particle is trying to figure a unified scheme for all its own ways to build (CLI, Dev, Build).
This might be the reason for the radio silence on this front
Stay tuned.
2 Likes
The only way I got it to work is to have all files of the project in a single directory. Not pretty but functional until the Dev gets this long awaited update.
Alternatively and if you are developing in linux, you can resort to soft links, so you soft link libraries in other folders to the DEV project folder of your project.
@gusgonnet Thanks for the hint. The symlink option is a good work around because you can also have separate git repos for your libs.
1 Like
@waspinator I have the same structure like you and I can include the libraries with #include <OneWire.h>
.
Just for nit picking, the preferred form would be #include "....."
since the angled brackets are usually kept for system libraries.
Ref
https://gcc.gnu.org/onlinedocs/gcc-2.95.3/cpp_1.html#SEC6
1 Like
@ScruffR Ok, got it. So the best way is to have a flat structure without folders until Particle provide better tools for Particle Dev?
You can have sub-folders if you supply a file list via a particle.include
file, but the #include
statements need to be as if you had a flat structure since the structure gets flattened on upload.