How to include Library files using Particle Build IDE

I am new to the Particle environment and I am working on a few projects to integrate and use Photon with Blynk. So far I have limited success although it is encouraging but I seem to be stuck on how to get my libraries linked into the development environment. I am struggling to find documentation or tutorials with the detailed steps on how to get my library files included in my applications.

I would appreciate any help in overcoming this hurdle through assistance or pointing me to the documented steps.

Many thanks…

If you use Web IDE (the web environment), you just specify the library (a selection button) you want and magic happens.

If you use Particle Dev, you will have to include the library code (.H, .cpp etc) into the same directory as where your .ino lives.

The include in your .ino will obviously also have to refer to the same location - #include “Fredlib.h”

I am not in front of my home computer so cannot give you any more info - but hopefully this will assist.

Stan

The documentation never hurts :wink:
https://docs.particle.io/guide/getting-started/build/photon/#using-libraries

Thanks Stan. Your response is very much appreciated. I am using the web IDE and I cannot find the directories where the .ino and other files are stored. Are you referring to the Atom IDE ?

It seems that my major problem is setting up the Github repository and pointing it to my cloud .ino

I much prefer to use the Workstation version (Atom) if that makes it easier.

Thanks again.

Thank you Moors7. and Stan. I finally figured it out. I did not notice the + icon at the top right of the Particle Build Web screen as I was focused on the vertical menu bar on the left. Such a simple thing caused me so much grief.

Regards

1 Like

I think I spoke too soon. In the Web IDE, the plus + button opens up new tabs .cpp and .h but I still cannot upload a .h file from my hard disk to the application environment in the particle cloud. Could you please lead me through the steps. By the way, I can load the header files such as blynk.h from the library within the IDE environment but cannot find the particular header file I would like for my application in that repository hence the need for me to upload it.

Thanks once again…

There currently isn’t a way to upload files in their entirety, but if you open them in a text editor you can just copy&paste the code.

1 Like

The web IDE doesn’t support uploading, although many libraries are available to be used. If you really need full freedom in your programming, I suggest you use Particle Dev, you can even upload code with it. It’s really quite nice and Atom of course supports a lot of features, syntaxing and overall just works better than a browser based IDE.

2 Likes

Len, I have loaded the Particle dev app in Windows 10 and I seem to be struggling with it as well. The environment looks good and I believe I have set up the project folder correctly. However I keep getting a compile error with the Blynk library. It is a simple LED example program but requires the <SimpleTimer.h> and I imagine the Blynk.h library. However the problem I am experiencing seems to be in setting up the libraries and continuously get errors such as xxxx.h file or directory not found although the file or files exist in the project folder. By the way, the Blynk library is quite large, do I install all the files into the project directory ? And if I have to do another small Blynk project do I have to copy all those library files to another directory ? Maybe I am missing something but it is quite frustrating…Thanks for any suggestions or guidance.

In Dev your includes need to be flat

#include "Blynk.h"
//#include "Blynk/Blynk.h" // this is for Build and won't work in Dev

That frustration will go away once the new Libraries 2.0 and IDEs 2.0 are released (not too long from now)
For the time being you need a local copy of each library you use. If you use them frequently, adding links to the libraries in your project folder shoukd work too. But your includes still need to be flat.

Doing a first time build in Parictle Desktop IDE v1.19.0 x64 and it has been frustrating and riddled with in documentation inaccuracies and even bugs. If you guys get a new intern at Particle, maybe have them load up two libraries that need each other using the IDE from scratch and see how they do without any outside help to compile and load the example in one of those libraries that requires the second library.

In the IDE version above, clicking on ‘Browse and Manage’ libraries brings up the library needed, however click on Use does not give any option to add to project nor does it even install the library visible under Project directory (a bug I presume), however if I click the ‘View Source’ button for that library, the library magically get installed correctly under Particle/community/libraries/CorrectFolderName/

Possible Bug #2 - If I load a project in the Particle desktop IDE such as blink and go up to the example directory and click Compile online, it works great. If I then click on an *.ino file in a different project folder and click compile online with the check box, it says it can’t find the blink.h file, which doesn’t make much sense, as there is no relationship to the blink project and this other project folder. Does that mean there is some pointer that must be set when you want to compile a *.ino in another folder?

Possible Bug #3 The only way I can load a project with a 3rd party library that compiles correctly is click on the Welcome Guide helper window on the right when the IDE first starts and click ‘Open a Project’ and then select the root of a project folder that has the src folder inside to load correctly. Loading using the File open project menu doesn’t seem to do the same thing, which is odd.

Bug #4 After the Project is loaded, if I click on the *.ino file under the Example directory and click the check box icon to compile in cloud and check for errors… nothing happens. However, if I click Menu option Particle–>Compile in the Cloud it correctly compiles a binary file and returns it back.

I can’t tell you how frustrating it is not to be able to load up multiple libraries and then to have access to them in a project without having to drag *.cpp *.h files into the src folder manually from the Library files. Additionally, all online documentation show a magical box for adding libraries that says “Add to Project” that never pops up when I click “Use”

As a side note, I’m also confused why there is no “Create new Project” option under the File pull down menu that creates a project and enters that project, however there is an icon to do so, however it will not enter that new project.

Please make a tutorial or video that clearly shows creating a new project and adding two or more 3rd party (non-particle verified) libraries to it such as LCD and a temperature sensor and compiling successfully. The current implementation is much more confusing than Arudino IDE that does not match the Particle documentation. As a final note, the documentation states that the *.ino and all libraries must be in the src folder, however the example *.ino only compiles when outside the src folder and not when moved inside, so again it does not match documentation. Thanks.

Particle Desktop IDE (aka Particle Dev) is not actively maintained anymore.
The go-to IDE for local develpment is VSCode based Particle Workbench

But

Not a bug, but by design. The Add to current project option only creates a dependency entry in project.properties for a cloud build to import it on the fly.
If you want it installed you should use the Copy to current project option (see below).

This IDE is not interested in which file you are currently editing, but only builds the project you selected earlier. If you want to switch project, you need to open the respective project via the open folder file menu entry.
After all, Atom (on which Desktop IDE is based on) is only a text editor - unaware of dependencies. So when you just switch files it won’t know to inform the extension about the switching.

“Bug #3” is a combination of both points above.

So is “Bug #4”, the compile task will compile the project referenced via the project.properties file in the project root folder - not the examples.
If you want to build an example, you need to create a project for that example.

How about this?
image

Yup, that’s not well thought out but won’t be changed due to discontinuation.
However, after you created the project you can use File - Open folder ... and select the folder you just created to switch over to the new project.

If you select the project properly the project.properties file will be used for building and then the behaviour will match the docu.