Resolving Conflicts Between Teensy and Adafruit SdFat Libraries

merrickMilo

New member
Hi everyone,

I'm working on a Teensy-based project that uses both the Teensy SD.h library (which depends on its custom SdFat) and the Adafruit SPIFlash library (which depends on the Adafruit-modified SdFat). I'm running into multiple definition errors and macro redefinition warnings like these:

"
multiple definition of `ostream::putNum(long)';
multiple definition of `ExFatPartition::checkUpcase(Print*)';
warning: "FILE_READ" redefined
"
and

"
Multiple libraries were found for "SdFat.h"
Used: /Users/merrickfort/Library/Arduino15/packages/teensy/hardware/avr/1.59.0/libraries/SdFat
Not used: /Users/merrickfort/TeensySketchbook/libraries/SdFat_-_Adafruit_Fork
exit status 1
"



I’ve tried separating the libraries as well as following this solution posted here:

This solution was promising but the adafruit package I was utilizing relies on the conflicting version as a dependencies and is included during the compilation process or when just including the header file. in other words I couldn't compile without the conflicting libraries being installed circling me around to the original issue

How can I ensure that the Teensy SD.h library uses its custom SdFat while the Adafruit SPIFlash library uses the Adafruit-modified SdFat without causing conflicts?

Any advice or examples would be greatly appreciated!
 
@merrickMilo
How can I ensure that the Teensy SD.h library uses its custom SdFat while the Adafruit SPIFlash library uses the Adafruit-modified SdFat without causing conflicts?

Any advice or examples would be greatly appreciated!
Unfortunately there is no way that I know of that you can use both at the same time without reworking the adafruit library which is probably not easy. Like changing the name of sdfat.h to sdfat_ada.h in all files in the their library. But if you are using there spiflash lib then have to make sure they are not calling it directly. Think the qspi lib using SDFAT_fork.h or something like that.

Even with that change not sure if there would be conflicts with naming on the other modules.
 
I will second what @mjs513 mentioned. That I have not found any way to use the different variations of the SDFat library with each other.

For example if you install the main SDFat library from either the Arduino Library Manager or directly from: https://github.com/greiman/SdFat
into the standard location (<sketch folder>/libraries/...) you can not compile any Teensy sketches that use SD directly or indirectly. And
non-teensy boards can not use the Teensy version.

Luckily the Adafruit fork of it has a different directory name, and the library detection code, will choose the Teensy version, when you
are building for a Teensy and will choose the Adafruit one for other boards. So at least they can coexist.

However as you have found, they can not both be used in the same sketch. Probably the only real solution, would be for both
forks to maybe change to for example have different Header file names, maybe different class names... Or potentially
someone needs to go through both (or all three) and do something to detect that others are also included and not redefine things, probably
#ifdef out portions of code, ... No ideas how difficult that might be.

Good luck
 
Thanks for the info, I'll keep looking into it but it seems like both of you are correct. Thank you again for saving from losing too much sleep over this
 
Back
Top