Photon2 compile errors when using custom library

I've finally received a few Photon2 devices and am trying to upgrade my Patriot IoT code and plug-in libraries. I tried just changing photon2 to the library architectures, re-uploading the libraries, and then recompiling the code (using --target 5.4.1) but I'm receiving a lot of errors. Here's an example:

My code uses a .ino file with many included custom libraries. The main include library (IoT) compiles and runs ok. The problem seems to be with any plugin libraries that use Wire to talk I2C to the NCD boards (eg. NCD's Photon 4 Relay + 4 GPIO PEIO4R4G5LE)

So I tried just copying the code from one library directly into the .ino file and it compiles and works!

This was all working before with the original Photon and the default os.
My repo is and I'm working in the photon2 and embed-ncd4s branches.

Is there a known problem with Photon2 (or maybe 5.4.1) and custom libraries?

@jalbersr - can you give this a look? I'm assuming it's a compatibility issue. When Rick's back next week it's worth verifying.

Maybe this thread reply by @rickkas7 could help? :

I came across it when I was researching why I was not able to cloud compile my workbench projects when local compile worked.

Thank you for the suggestion. I am not building locally, but am using the CLI cloud compile/flash commands: "particle compile photon2 --target 5.4.1" and "particle flash mycontroller --target 5.4.1".

My statement above is incorrect about the problem occurring with libraries using Wire. I'm also seeing it with plugins not using I2C at all, and just using pins directly. The only workaround I've found is to copy/paste the custom library code into the .ino file. That makes for a very large .ino file :slight_smile:

Update: at this point I've stopped using multiple custom libraries and I am just including all source in a single library. This is working with Photon 2 now (on 5.4.1) although not as convenience to manage.

Hi @ronlisle!

I managed to reproduce your issue but I'm still looking at the solution. It's weird that the exact code works outside the libraries but not inside them. This is a little outside my expertise, maybe @rickkas7 knows what is happening. But still, let me ask the team for insight.

It's almost certainly a conflict between defines in one library and another library, which is hard to solve generically. Making your own custom version is one reasonable solution.

Another is to use Workbench pseudo-library structure, which works with both cloud and local compiles. Basically you populate the public library, modify your, then you can modify the public library and use the modified version without having to publish it.