# Local Libraries + Workbench

**URL:** <https://community.particle.io/t/local-libraries-workbench/56728>\
**Category:** Developer Tools\
**Created:** [June 19, 2020, 9:14pm UTC](https://community.particle.io/t/local-libraries-workbench/56728 "2020-06-19T21:14:25Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![outoftolerance](https://avatars.discourse-cdn.com/v4/letter/o/b782af/32.png) [@outoftolerance](https://community.particle.io/u/outoftolerance)\
**Post date:** [June 19, 2020, 9:14pm UTC](https://community.particle.io/t/local-libraries-workbench/56728/1 "2020-06-19T21:14:25Z")

</div>

Hi Folks,

I’ve read about every docs page and community post I can find on local libraries and their structure and how to use them in Workbench but the picture is still unclear to me as to what Workbench is expecting in order to compile local libraries. Usually the answer to others questions is “Create a demo project and copy the structure” but sometimes that’s just not possible when wanting to bring in pre-existing libraries and it appears that my library is already following that structure but I’m still facing an error.

Currently I understand the following must be true:

- Libraries must be within their own folder in the “libs” or “libraries” folder of a project
- Libraries must have a libraries.properties file
- Libraries must have their .h and .cpp files within an “src” folder inside the library folder

I have a library I am trying to port over to use on a Particle Boron from an Arduino project and it’s structured according to the above rules however it’s not able to be found by the compiler.

```auto
Creating c:/Users/<username>/Documents/GitHub/icarus_firmware/target/1.5.2/boron/platform_user_ram.ld ...
In file included from c:/Users/<username>/Documents/GitHub/icarus_firmware/libraries/SimpleHDLC/src/SimpleHDLC.cpp:1:0:
c:/Users/<username>/Documents/GitHub/icarus_firmware/libraries/SimpleHDLC/src/SimpleHDLC.h:7:21: fatal error: FastCRC.h: No such file or directory
compilation terminated.

```

You can find the project and the specific library I am referring to here: [https://github.com/outoftolerance/icarus\_firmware/tree/master/libraries/FastCRC](https://github.com/outoftolerance/icarus_firmware/tree/master/libraries/FastCRC)

I’ve tried a number of different experiments with naming, file locations, etc but can’t seem to get it to compile, any insight as to why the compiler can’t find the file would be much appreciated!

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [June 19, 2020, 9:56pm UTC](https://community.particle.io/t/local-libraries-workbench/56728/2 "2020-06-19T21:56:08Z")

</div>

> [@outoftolerance](#):
>
> Usually the answer to others questions is “Create a demo project and copy the structure”

Hmm, I don't think that's the way to do it.  
If you want to build a library you should use `particle library create`

> [@outoftolerance](#):
>
> within their own folder in the “libs” or “libraries” folder of a project

I don't know about the _or "libraries"_ part, I'd stick with "lib" and only that.

BTW, does `<username>` happen to contain blanks? If so, that may be the issue.

---

<div class="post-metadata">

**Author:** ![outoftolerance](https://avatars.discourse-cdn.com/v4/letter/o/b782af/32.png) [@outoftolerance](https://community.particle.io/u/outoftolerance)\
**Post date:** [June 19, 2020, 11:35pm UTC](https://community.particle.io/t/local-libraries-workbench/56728/3 "2020-06-19T23:35:00Z")

</div>

Thanks @ScruffR.

`<username>` does not contain any spaces or special characters, it’s just lowercase alphabet chars.

One of the experiments I ran was changing from “libraries” to “lib” and “libs” and that didn’t change the issue, it appears to me that Workbench compiles with either option and I’d prefer to use “libraries” because there are other .ino files in the project that I am compiling with Arduino IDE which uses this name.

I did create a library with `particle library create` to ensure that my properties file and file structure matched, which they do.

Is it required that the .h and .cpp files have the same name?

This library I am porting has `FashCRC.h` but no `FastCRC.cpp` file, the cpp files are structured differently. I did try re-naming the files as such but it didn’t compile, maybe I didn’t do it correctly if this is a requirement…

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [June 20, 2020, 12:25am UTC](https://community.particle.io/t/local-libraries-workbench/56728/4 "2020-06-20T00:25:23Z")

</div>

> [@outoftolerance](#):
>
> Is it required that the .h and .cpp files have the same name?

Nope, this is not required. But for clarity it is always good to have at least one header file that matches the library name. Apart from that, your library can consist of many files of various names as long things are consistent (i.e. include statements refer to the correct files) and don't clash with other file names present in the project.

> [@outoftolerance](#):
>
> there are other .ino files in the project

However, this might be also contributing to the issue.  
Usually we advise people to only have _one_ .ino file in a project to prevent confusion - particularly for the Wiring preprocessor.

Unfortunately both my dev machines recently died on me, so I cannot really test stuff for myself till I get a new machine set up.

---

<div class="post-metadata">

**Author:** ![outoftolerance](https://avatars.discourse-cdn.com/v4/letter/o/b782af/32.png) [@outoftolerance](https://community.particle.io/u/outoftolerance)\
**Post date:** [June 21, 2020, 12:44am UTC](https://community.particle.io/t/local-libraries-workbench/56728/5 "2020-06-21T00:44:16Z")

</div>

Thanks, the library and my files seem like they should match the correct structure.

I tried removing all other .ino files in the project but have the same error. Is there a way to access the compiler and linker settings/configuration in Workbench?

I’d be really grateful if you could try to compile once you’ve got a working setup again!

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [June 21, 2020, 6:54am UTC](https://community.particle.io/t/local-libraries-workbench/56728/6 "2020-06-21T06:54:23Z")

</div>

Can you pack your entire project in a zip file and PM me a link (e.g. Google Drive) or upload the project to GitHub?

---

<div class="post-metadata">

**Author:** ![outoftolerance](https://avatars.discourse-cdn.com/v4/letter/o/b782af/32.png) [@outoftolerance](https://community.particle.io/u/outoftolerance)\
**Post date:** [June 22, 2020, 2:50am UTC](https://community.particle.io/t/local-libraries-workbench/56728/7 "2020-06-22T02:50:04Z")

</div>

The GitHub link is here: [https://github.com/outoftolerance/icarus\_firmware/tree/master/](https://github.com/outoftolerance/icarus_firmware/tree/master/)

---

<div class="post-metadata">

**Author:** ![outoftolerance](https://avatars.discourse-cdn.com/v4/letter/o/b782af/32.png) [@outoftolerance](https://community.particle.io/u/outoftolerance)\
**Post date:** [June 24, 2020, 6:38pm UTC](https://community.particle.io/t/local-libraries-workbench/56728/8 "2020-06-24T18:38:59Z")

</div>

Does anyone else know if the compiler and linker settings are available somewhere to be tweaked?

---

<div class="post-metadata">

**Author:** ![m\_m](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/m_m/32/18365_2.png) [@m\_m](https://community.particle.io/u/m_m)\
**Post date:** [June 24, 2020, 7:30pm UTC](https://community.particle.io/t/local-libraries-workbench/56728/9 "2020-06-24T19:30:46Z")

</div>

there are a number of options you can explore - they all come with the standard disclaimer: _for advanced users only_.

first, you can interact with Workbench’s local compiler by running `Particle: Launch Compiler Shell` - it prints out basic usage info when you invoke the command.

Workbench sits on top of the Device OS’ build system - (somewhat) documented here:

[https://github.com/particle-iot/device-os/blob/v1.5.2/docs/build.md](https://github.com/particle-iot/device-os/blob/v1.5.2/docs/build.md) (note: you should reference the docs for the specific version of the Device OS you are targeting)

Device OS’ build system supports extension via a custom `./src/build.mk` file - visit:

> **[Local build using gcc-arm](https://support.particle.io/hc/en-us/articles/360039741273-Local-build-using-gcc-arm)**
>
> Local build using gcc-arm
> It is possible to build both application firmware and Device OS locally using the gcc-arm toolchain on Windows, Mac and Linux. There are a few reasons you might be interes...

…then scroll down until you see the section labeled " Including additional header directories" (we’re working on creating direct links to these)

you can basically ignore all directions to install custom toolchain bits as this is what WB does for you the caveat being that you’ll need to run within WB for now.

hope that helps, good luck 👍

---

<div class="post-metadata">

**Author:** ![nrobinson2000](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/nrobinson2000/32/15624_2.png) [@nrobinson2000](https://community.particle.io/u/nrobinson2000)\
**Post date:** [June 24, 2020, 10:19pm UTC](https://community.particle.io/t/local-libraries-workbench/56728/10 "2020-06-24T22:19:57Z")

</div>

Also, for anyone looking to use the build system outside of Workbench I’ve been working on a feature-complete utility for the last month.

> [@Neopo: A lightweight solution for local Particle development](https://community.particle.io/t/neopo-a-lightweight-solution-for-local-particle-development/56378):
>
> Hello everyone. I am proud to announce the release of [neopo](https://neopo.xyz/), a utility for locally building and flashing Particle projects to Particle devices that integrates with Particle Workbench. TL;DR I’ve made a replacement for po and po-util written in Python that is fully compatible with Particle Workbench and particle-cli. Here is the GitHub repository: You can install neopo with the following command: $ bash \<( curl -sL https://git.io/JfwhJ ) Story Four years ago I created po-util, a …

> **[GitHub - nrobinson2000/neopo: A lightweight solution for local Particle...](https://github.com/nrobinson2000/neopo)**
>
> A lightweight solution for local Particle development. - GitHub - nrobinson2000/neopo: A lightweight solution for local Particle development.

---

<div class="post-metadata">

**Author:** ![outoftolerance](https://avatars.discourse-cdn.com/v4/letter/o/b782af/32.png) [@outoftolerance](https://community.particle.io/u/outoftolerance)\
**Post date:** [June 28, 2020, 10:46pm UTC](https://community.particle.io/t/local-libraries-workbench/56728/11 "2020-06-28T22:46:29Z")

</div>

Thanks @m_m! I was able to restructure the project using the Extended Project Structure and add a custom build.mk file that explicitly included by libraries directory, it built first go!

The solution looked as follows and is a really neat way to build multiple source files, Arduino and Particle, from a single project that share libraries with one another (in my case this is because I have multiple devices communicating with each other and I want to share things like the message protocol libraries).

- Project Dir
- project.properties
- libraries
  - libraryName
    - library.properties
    - src
      - libraryName.h
      - libraryName.cpp

- src
  - build.mk
  - first\_app
    - first\_app.ino

  - other\_app
    - other\_app.ino

The build.mk file ended up looking like this:

```auto
# Standard behavior must be included here
INCLUDE_DIRS += $(SOURCE_PATH)/$(USRSRC) # add user sources to include path
CPPSRC += $(call target_files,$(USRSRC_SLASH),*.cpp)
CSRC += $(call target_files,$(USRSRC_SLASH),*.c)

APPSOURCES=$(call target_files,$(USRSRC_SLASH),*.cpp)
APPSOURCES+=$(call target_files,$(USRSRC_SLASH),*.c)

# Custom stuff can be added here
INCLUDE_DIRS += $(SOURCE_PATH)/libraries

```

This can now be seen in my GitHub repo here for anyone looking for a future reference: [https://github.com/outoftolerance/icarus\_firmware/tree/624dfec59c3a1975fe120b5e97f90049ecb62d5e](https://github.com/outoftolerance/icarus_firmware/tree/624dfec59c3a1975fe120b5e97f90049ecb62d5e)

---

<div class="post-metadata">

**Author:** ![outoftolerance](https://avatars.discourse-cdn.com/v4/letter/o/b782af/32.png) [@outoftolerance](https://community.particle.io/u/outoftolerance)\
**Post date:** [June 28, 2020, 10:49pm UTC](https://community.particle.io/t/local-libraries-workbench/56728/12 "2020-06-28T22:49:26Z")

</div>

Update: You don’t even need the build file, it appears just nesting the \*.ino files into a “src” directory solves the problem.

---

<div class="post-metadata">

**Author:** ![m\_m](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/m_m/32/18365_2.png) [@m\_m](https://community.particle.io/u/m_m)\
**Post date:** [June 29, 2020, 3:51pm UTC](https://community.particle.io/t/local-libraries-workbench/56728/13 "2020-06-29T15:51:40Z")

</div>

@outoftolerance glad you got things sorted out and thanks for sharing your notes 👍

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/3/2/3291e3c9351789fe8620ae5bcec8d3fec67ff221.png) [@system](https://community.particle.io/u/system)\
**Post date:** [December 29, 2020, 3:51am UTC](https://community.particle.io/t/local-libraries-workbench/56728/14 "2020-12-29T03:51:52Z")

</div>

Closed on December 29, 2020, 3:51am UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
