queezythegreat / arduino-cmake

Arduino CMake Build system
648 stars 216 forks source link

Sketch using SdFat fails to link certain functions #184

Open mweber-ovt opened 5 years ago

mweber-ovt commented 5 years ago

SdFat links correctly in the Arduino IDE. However, the use of certain functions in a sketch using SdFat results in linker errors as follows:

[100%] Linking CXX executable BGC_4G.elf
libmega_rawdata.a(rawdata.cpp.obj): In function `RAWDATA::store(EVENT, TrapStatus)':
/.../BGC_4G/lib/rawdata/rawdata.cpp:107: undefined reference to `FatFile::printField(int, char)'
collect2: error: ld returned 1 exit status

The recursive option is set for SdFat.

There is a header file SdFat/src/FatLib/FatFile.h which defines the prototypes for FatFile member functions including printField. However, the code for printField itself is in a file FatFilePrint.cpp. Moving it to the file FatFile.cpp eliminates the linker error but that seems like a dangerous workaround.

I am very new to CMake and I wonder if this is a bug or if anybody has a suggestion for what I could do to avoid this error?