V2 Libraries not auto loading

I just posted some code that does not work by simply pasting the code into the particle IDE because it uses the new V2 libraries. You have to find and insert the library!

The above code did not format well so here is the relevant part again:

// This #include statement was automatically added by the Particle IDE.
#include <adxl362.h>

//#include “adxl362.h”

//#include <adxl362/adxl362.h>

//#include “adxl362/adxl362.h”

ADXL362 xl;

A couple of minor problems:

  1. “less than” quotes do not paste well into this blog. you have to use &-#060; (without the dash) or &-lt; (once again without the dash)

  2. Pasting “> #include” makes that line bold unless you insert another space between the “>” and the “#include

  3. Pasting the code into the IDE then does not work!. You have to go through the steps of finding the library and including it into the project.

This last issue, I assume is difficult to solve, but does make examples very frustrating for beginners. Is there any plan to try to fix this?


Is there a plan for a set statement about how to load the libraries to find the correct library to insert. Something like

// For this example to work, please load the library ADXL362 and include it in this project

Not ideal, but better than the present situation where the example code simply does not work.

OR This code be auto generated:

// This #include statement was automatically added by the Particle IDE
// If the following line gets an error please re-include the file from the Particle library

1 Like


If you use:

Your "code" goes.here()

Your code will be formatted properly on the forums.

Your "code" goes.here()

This is why you need to wrap code blocks in a set of these

 // code here

There is a thread providing forum hints

***Quoting*** text blocks does the translation from `>` to `&gt;` and `<` to `&lt;`

And when contributing a library you should also provide a usage sample that can be taken as is by use of the <kbd>USE THIS EXAMPLE</kbd> button in Web IDE's library drawer.

And adding a *prerequisites* comment in your code should be enough for any user to know to import the library.
After all you also need to provide some info about wiring for your sensors anyway - there won't be any *"set satement"* to auto-wire either ;-)
Some minimal self-involvement of users can be expected IMHO.
1 Like

Thanks @ScruffR and @nrobinson2000 I did not know about using the three back dashes `

This now inserts very easily

// This #include statement was automatically added by the Particle IDE.
#include <adxl362.h>

//#include "adxl362.h"

//#include <adxl362/adxl362.h>

//#include "adxl362/adxl362.h"

ADXL362 xl;



And I think @ScruffR has a sensible idea here that we all try to give both Photon connection hints and include file hints, helpful links etc probably at the top of the page after the license information. Most of us have been giving the connection hints, just now add the include file hints.


P.S. Any idea why the old method is not working anymore, because it was very slick. (Come to think of it, this method probably did not work and that is why I was not enjoying using libraries so I had my students attach include files to the .ino file. This one is my mistake.)

#include "adxl362/adxl362.h"

and could it be replaced by a compiler directive?

I’m not quite sure what you are refering to.
Only adding the respecive #include statement was never enough in the particle world (apart from framework and system components).
Also if you have CLI migrate a legacy library to v2.0 you’ll see an extra subdirectory with some legacy header files to ensure the previous #include "libName/libName.h"still works.
But the big advantage of Libs v2.0 is that a library or project can now state dependencies and the user does not need to import any secondary libraries.

1 Like

Unfortunately (include files working out of the box) is the standard with most modern successful Linux compilers. Think about how much effort has been put into nodejs npm, (Node Package manager) so that packages just work, right out of the box.

Who are the main IDE and V2 Library Particle Engineers?

Unless it is a security issue, I don’t think it would be a huge programming job to have the

#include <something.h>

activate the few steps it would take to auto load the libraries. (Would occasionally cause issues with duplicate include file names but the benefit would be huge. Code from the internet compiling immediately, no errors, no extra steps )

The easier Particle is to operate can only make your product better.