Add vs Copy with library desktop IDE library manager

Hey,

I’m trying to understand how the new Extended Structure way of organizing projects and wrap my mind around the new Library Manager feature available in the latest Particle desktop IDE.

I seem to be able to compile OK when I “Add” a “Library” to my “Project”.

However, when I “Copy” a “Library” to my “Project”, the files get added to MyProject/lib, and when I go to compile the project I get hit with a “No such file or directory” error as shown in the following screenshot:

_
_
_
_
Question:
How does one use a library that is “Copied” to a Particle Project instead of “Added”?

A little background:

I am used to using the “Legacy Structure” when working with my projects, and have never used the “.ino” workflow before (i.e. I always just have a main.cpp file that contains a #include “Particle.h” line at the beginning ). I don’t fully understand what a .ino file does. Does it just add that include statement by default, or are there other differences between using “.ino” and “.cpp”?

I believe the error is covering the correct include path which you might need to uncomment?

Nope, that was my own feeble attempt at fixing the problem, and it didn’t work :sweat_smile:

Update:

Okay, I can get compilation to work from Particle CLI, but not from within Particle Dev when a library is copied

With Particle Dev it doesn’t work. Here is what happens:

with Particle-CLI, it works. Here is what happens:

C:\Users\Boompy\Documents\Particle\projects\SDTest_Copy>particle compile electron

Compiling code for electron

Including:
    lib\SdFat\src\ArduinoFiles.h
    lib\SdFat\src\ArduinoStream.h
    lib\SdFat\src\bufstream.h
    lib\SdFat\src\FatApiConstants.h
    lib\SdFat\src\FatFile.h
    lib\SdFat\src\FatFileSystem.h
    lib\SdFat\src\FatLib.h
    lib\SdFat\src\FatLibConfig.h
    lib\SdFat\src\FatStructs.h
    lib\SdFat\src\FatVolume.h
    lib\SdFat\src\FmtNumber.h
    lib\SdFat\src\FreeStack.h
    lib\SdFat\src\fstream.h
    lib\SdFat\src\ios.h
    lib\SdFat\src\iostream.h
    lib\SdFat\src\istream.h
    lib\SdFat\src\ostream.h
    lib\SdFat\src\SdFat.h
    lib\SdFat\src\SdFat\ArduinoFiles.h
    lib\SdFat\src\SdFat\ArduinoStream.h
    lib\SdFat\src\SdFat\bufstream.h
    lib\SdFat\src\SdFat\FatApiConstants.h
    lib\SdFat\src\SdFat\FatFile.h
    lib\SdFat\src\SdFat\FatFileSystem.h
    lib\SdFat\src\SdFat\FatLib.h
    lib\SdFat\src\SdFat\FatLibConfig.h
    lib\SdFat\src\SdFat\FatStructs.h
    lib\SdFat\src\SdFat\FatVolume.h
    lib\SdFat\src\SdFat\FmtNumber.h
    lib\SdFat\src\SdFat\FreeStack.h
    lib\SdFat\src\SdFat\fstream.h
    lib\SdFat\src\SdFat\ios.h
    lib\SdFat\src\SdFat\iostream.h
    lib\SdFat\src\SdFat\istream.h
    lib\SdFat\src\SdFat\ostream.h
    lib\SdFat\src\SdFat\SdFat.h
    lib\SdFat\src\SdFat\SdFatConfig.h
    lib\SdFat\src\SdFat\SdInfo.h
    lib\SdFat\src\SdFat\SdSpi.h
    lib\SdFat\src\SdFat\SdSpiCard.h
    lib\SdFat\src\SdFat\SoftSPIParticle.h
    lib\SdFat\src\SdFat\StdioStream.h
    lib\SdFat\src\SdFat\SysCall.h
    lib\SdFat\src\SdFat\SystemInclude.h
    lib\SdFat\src\SdFatConfig.h
    lib\SdFat\src\SdInfo.h
    lib\SdFat\src\SdSpi.h
    lib\SdFat\src\SdSpiCard.h
    lib\SdFat\src\SoftSPIParticle.h
    lib\SdFat\src\StdioStream.h
    lib\SdFat\src\SysCall.h
    lib\SdFat\src\SystemInclude.h
    src\SDTest_Copy.ino
    lib\SdFat\examples\bench\bench.cpp
    lib\SdFat\examples\DirectoryFunctions\DirectoryFunctions.cpp
    lib\SdFat\examples\LowLatencyLogger\LowLatencyLogger.cpp
    lib\SdFat\examples\OpenNext\OpenNext.cpp
    lib\SdFat\examples\ReadCsvArray\ReadCsvArray.cpp
    lib\SdFat\examples\ReadCsvFields\ReadCsvFields.cpp
    lib\SdFat\examples\SdFormatter\SdFormatter.cpp
    lib\SdFat\examples\SdInfo\SdInfo.cpp
    lib\SdFat\examples\Timestamp\Timestamp.cpp
    lib\SdFat\examples\TryMeFirst\TryMeFirst.cpp
    lib\SdFat\examples\VolumeFreeSpace\VolumeFreeSpace.cpp
    lib\SdFat\src\FatFile.cpp
    lib\SdFat\src\FatFileLFN.cpp
    lib\SdFat\src\FatFilePrint.cpp
    lib\SdFat\src\FatFileSFN.cpp
    lib\SdFat\src\FatVolume.cpp
    lib\SdFat\src\FmtNumber.cpp
    lib\SdFat\src\fstream.cpp
    lib\SdFat\src\istream.cpp
    lib\SdFat\src\ostream.cpp
    lib\SdFat\src\SdFat.cpp
    lib\SdFat\src\SdSpiCard.cpp
    lib\SdFat\src\SdSpiParticle.cpp
    lib\SdFat\src\StdioStream.cpp
    project.properties
attempting to compile firmware
downloading binary from: /v1/binaries/58d44f00b7483512ec8efe66
saving to: electron_firmware_1490308850959.bin
Memory use:
   text    data     bss     dec     hex filename
  13676       8    2884   16568    40b8
Compile succeeded.
Saved firmware to: C:\Users\Boompy\Documents\Particle\projects\SDTest_Copy\electron_firmware_1490308850959.bin

Now…

If I copy all the files in the root\lib\SdFat\src folder into the root\src folder, and delete root\lib I can get the Desktop IDE to compile (as shown below…)

This also works if I group all the files I copied into a folder within src named “SdFat”:

So, it would appear that there is a problem with Desktop IDE wherein compilation only works when a Library is “Added” instead of “Copied”.

I have also replicated this issue with the OneWire library.

So, looks like the moral of the story is the Particle Dev doesn’t compile correctly unless you Add the library (not Copy it) or copy its source files into your “src” folder

I’d have to test your explicit case myself, but I know the feature works when the libraries are ported correctly and the project is set up right.

But unless you need to customise the library (e.g. make it build again after a poor port/migrate) you should rather use USE + Add to current project to only get the dependency added to project.properties instead of downloading the sources.
That also works for .cpp projects, not just .ino.

Also to note:
Complex libraries with deeper file structure (as SdFat is) are currently not too well supported when copied to your project.
Particle is working on that tho’

1 Like

I agree, there is no real reason to use “Copy” instead of “Add” unless you want to modify the library.

Thanks for everyone’s input on this, the Particle suite of development tools keeps getting better and better and a few minor glitches on the way to greatness are affordable methinks :satellite:

1 Like

After playing a bit more with Copy to current project I found some extra hurdles to be aware of and which should get corrected by Particle.
Hence I filed a GitHub issue about that

1 Like