Creating a Library

I’m trying to create a library from a module I’ve been reusing for a while. I’ve found some help at https://docs.particle.io/tutorials/device-os/libraries/#contributing-libraries but I’m not sure how to setup Particle Workbench to allow me to build and run the samples.

I can’t import the project because there is no project.properties file generated. I could just create a new particle project and copy the files over but that doesn’t seem like the best way.

How do I import a library generated by “particle library create” into workbench and work with it?

@ParticleD, @m_m or @mstanley are you able to assist?

I think Workbench questions are best directed to @m_m

However @sho, you can upload a work-in-progress library via particle library upload for your private use only. That way you can install it just as any other library.

Or the manual way without uploading first is to create a new project, add a lib subfolder into which you copy <yourLibraryFolder>.
After that you should have a project structure like that

.
│   project.properties
│   README.md
│
├───lib
│   └─── yourLibrary
│       │   library.properties
│       │   LICENSE
│       │   README.md
│       │
│       ├───examples
│       │   └───yourTest
│       │           project.properties
│       │           yourTest.ino
│       │
│       └───src
│               yourLibrary.cpp
│               yourLibrary.h
│
└───src
        test.ino
3 Likes

Thanks @ScruffR. I’ve tried the method you mention but I get errors about header files not being found when I structure my library that way. Do I need to manually add the include paths in Workbench?

Nope, you shouldn’t need to add paths when you use the standard layout.
Can you zip your project and send me a link (e.g. Dropbox, Google Drive, One Drive, …) via PM to have a look at?

1 Like

PM Sent with the library that was generated.

I’ve also tried creating that same structure in many existing projects to organize my included files and the source files are compiled but VS can’t find the headers.

I see you haven’t got a file dbLogWriter.h nor any dependency that would reference such a file in your library but yet have this #include "dbLogWriter.h" statement in dbLogger.h.
How would you expect that not to throw an error?

1 Like