Multiple Library Dependency Issues

I posted this question a few days ago. I’ve made a little bit of progress, but am still very confused and frustrated. I have multiple issues, but for now I’ll stay focused on my issue with the CRC library. Here’s my platformio.ini:

[env:teensy40]
platform = teensy
board = teensy40
framework = arduino
lib_ldf_mode = chain+
lib_deps =
	elapsedMillis
	robtillaart/CRC @ ^0.3.0
lib_extra_dirs =
	/Users/keith/Documents/PlatformIO/Projects/EFD_libraries

When I delete the .pio folder and do a clean build, I get:

Unpacking  [####################################]  100%
Library Manager: elapsedMillis @ 1.0.6 has been installed!
Library Manager: Installing robtillaart/CRC @ ^0.3.0

Unpacking  [------------------------------------]    0%
Unpacking  [#-----------------------------------]    2%

Unpacking  [####################################]  100%
Library Manager: CRC @ 0.3.0 has been installed!
Found 107 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <elapsedMillis> 1.0.6
|-- <CRC> 0.3.0
|   |-- <FireScript2>
|   |   |-- <ColorUtilsHsi>
|   |   |-- <SdFileMgr>
|   |   |   |-- <SPI> 1.0
|   |   |   |-- <SD> 2.0.0
|   |   |   |   |-- <SdFat> 2.1.0
|   |   |   |   |   |-- <SPI> 1.0
|   |   |   |   |-- <SPI> 1.0
|   |   |   |-- <SdFat> 2.1.0
|   |   |   |   |-- <SPI> 1.0
|   |   |-- <SPI> 1.0
|   |   |-- <SD> 2.0.0
|   |   |   |-- <SdFat> 2.1.0
|   |   |   |   |-- <SPI> 1.0
|   |   |   |-- <SPI> 1.0
|   |   |-- <SdFat> 2.1.0
|   |   |   |-- <SPI> 1.0
|-- <FireScript2>
|   |-- <ColorUtilsHsi>
|   |-- <SdFileMgr>
|   |   |-- <SPI> 1.0
|   |   |-- <SD> 2.0.0
|   |   |   |-- <SdFat> 2.1.0
|   |   |   |   |-- <SPI> 1.0
|   |   |   |-- <SPI> 1.0
|   |   |-- <SdFat> 2.1.0
|   |   |   |-- <SPI> 1.0
|   |-- <SPI> 1.0
|   |-- <SD> 2.0.0
|   |   |-- <SdFat> 2.1.0
|   |   |   |-- <SPI> 1.0
|   |   |-- <SPI> 1.0
|   |-- <SdFat> 2.1.0
|   |   |-- <SPI> 1.0
|-- <ColorUtilsHsi>
|-- <SdFileMgr>
|   |-- <SPI> 1.0
|   |-- <SD> 2.0.0
|   |   |-- <SdFat> 2.1.0
|   |   |   |-- <SPI> 1.0
|   |   |-- <SPI> 1.0
|   |-- <SdFat> 2.1.0
|   |   |-- <SPI> 1.0
|-- <SPI> 1.0
|-- <SD> 2.0.0
|   |-- <SdFat> 2.1.0
|   |   |-- <SPI> 1.0
|   |-- <SPI> 1.0
|-- <SdFat> 2.1.0
|   |-- <SPI> 1.0
Building in release mode

Compiling .pio/build/teensy40/lib9eb/FireScript2/SlicBus.cpp.o
src/SlicBus.cpp:22:19: fatal error: CRC16.h: No such file or directory

***************************************************************
* Looking for CRC16.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:CRC16.h"
* Web  > https://registry.platformio.org/search?q=header:CRC16.h
*
***************************************************************

compilation terminated.
*** [.pio/build/teensy40/lib9eb/FireScript2/SlicBus.cpp.o] Error 1
======================================================================= [FAILED] Took 15.50 seconds =======================================================================

In the libdeps folder I can see the CRC folder and the CRC16.h header file, but it’s still not being found during compilation. The only way to get the program to compile is to copy the CRC16.h file (and another header file that it references) into my top level include folder. But I shouldn’t have to do that.

What’s going on? Is there something strange about the CRC library, am I doing something wrong, or is PIO having a problem?

Can you upload a minimal project that reproduces this problem to Github?

Max, thanks for getting back to me. I’ve been pulling my hair out for a week, but yesterday I was able to compile successfully. I was having multiple issues, and the example I gave here was just one of them. I’m not sure exactly what I did to fix the problems, but I have a theory:

I was having a very persistent problem with the SD library (“SD.h: No such file or directory”), similar to the problem I was having with the CRC library. I was using lib_deps = arduino-libraries/SD @ ^1.2.4. After re-reading the PIO/LDF documentation and playing with some pio commands, I realized that an SD library is included in there Teensy platform. So after changing to just lib_deps = SD that particular problem went away. Some kind of conflict between the two different libraries with the same names?

Similarly (but not exactly the same), I was having an issue with the CRC library when using lib_deps = robtillaart/CRC @ ^0.3.0. Again, I realized that the Teensy package includes a FastCRC library. The names aren’t the same, but when I switched to just lib_deps = FastCRC, the problem seemed to away.

The compiler was also frequently having trouble finding header files for my own private libraries. I was finally able to eliminate these problems by using the following tactics:

  1. Always use lib_ldf_mode = chain+
  2. Specify the full pathname to my libraries folder using
    lib_extra_dirs = /Users/keith/Documents/PlatformIO/Projects/EFD_libraries
  3. Specify each private library dependency using just the library name, not the full path, e.g.:
lib_deps = 
    ColorUtilsHsi
    FireScript
  1. Ensuring that all header files for my libraries are #included in a header file, not exclusively in a source file.
  2. Cleaning the build environment and deleting the .pio folder after making dependency changes (hopefully this isn’t always required).

I’m not 100% confident that my problems won’t return, but I seem to be OK for the moment. But I’d still appreciate hearing what you think.
Thanks! - Keith

1 Like