Go Down

Topic: Linking Issues with SdFat Library on Arduino Due (Read 524 times) previous topic - next topic

ssnover95

Hello,

I'm currently writing a data logging application to be implemented on the Arduino Due. I'm having trouble compiling in the Arduino IDE v 1.8.1. I've downloaded the library from it's GitHub repo and placed the SdFat directory and all of its contents into the usual Arduino/libraries/ directory.

In my sketch app.ino file, I've included in this order:
Code: [Select]
#include <SPI.h>
#include "sdCard.h"
#include <SdFat.h>


Additionally, in the sketch file app.ino I've declared a global variable SdBaseFile logfile and a function logResults() uses this object. In sdCard.h, I've implemented simple function to do define a couple simple functions to abstract away the majority of the library from app.ino.

sdCard.h has include directives:
Code: [Select]
#include <SPI.h>
#include <FreeStack.h>
#include <MinimumSerial.h>
#include <SdFat.h>
#include <SdFatConfig.h>
#include <SdFatUtil.h>
#include <SystemInclude.h>


... and sdCard.cpp declares a global module variable SdFat sd which is used in two of the functions for initializing and reading filenames on the card for generating a new file name.

When I compile the application, it fails on the linking step. Here's a copy of the output from the compilation process:
Code: [Select]
C:\Users\ssnover\AppData\Local\Temp\arduino_build_178533\sketch\app.ino.cpp.o: In function `FatFile::write(char const*)':

C:\Users\ssnover\Documents\Arduino\libraries\SDFat/FatLib/FatFile.h:886: undefined reference to `FatFile::write(void const*, unsigned int)'

C:\Users\ssnover\AppData\Local\Temp\arduino_build_178533\sketch\app.ino.cpp.o: In function `FatFile::open(char const*, unsigned char)':

C:\Users\ssnover\Documents\Arduino\libraries\SDFat/FatLib/FatFile.h:551: undefined reference to `FatFile::open(FatFile*, char const*, unsigned char)'

C:\Users\ssnover\AppData\Local\Temp\arduino_build_178533\sketch\app.ino.cpp.o: In function `logResults()':

C:\Users\ssnover\Desktop\app/app.ino:766: undefined reference to `FatFile::close()'

C:\Users\ssnover\Desktop\app/app.ino:767: undefined reference to `FatFile::m_cwd'

C:\Users\ssnover\AppData\Local\Temp\arduino_build_178533\sketch\sdCard.cpp.o: In function `SdFatBase::readBlock(unsigned long, unsigned char*)':

C:\Users\ssnover\Documents\Arduino\libraries\SDFat/SdFat.h:251: undefined reference to `SdSpiCard::readBlock(unsigned long, unsigned char*)'

C:\Users\ssnover\AppData\Local\Temp\arduino_build_178533\sketch\sdCard.cpp.o: In function `SdFatBase::writeBlock(unsigned long, unsigned char const*)':

C:\Users\ssnover\Documents\Arduino\libraries\SDFat/SdFat.h:254: undefined reference to `SdSpiCard::writeBlock(unsigned long, unsigned char const*)'

C:\Users\ssnover\AppData\Local\Temp\arduino_build_178533\sketch\sdCard.cpp.o: In function `SdFatBase::readBlocks(unsigned long, unsigned char*, unsigned int)':

C:\Users\ssnover\Documents\Arduino\libraries\SDFat/SdFat.h:257: undefined reference to `SdSpiCard::readBlocks(unsigned long, unsigned char*, unsigned int)'

C:\Users\ssnover\AppData\Local\Temp\arduino_build_178533\sketch\sdCard.cpp.o: In function `SdFatBase::writeBlocks(unsigned long, unsigned char const*, unsigned int)':

C:\Users\ssnover\Documents\Arduino\libraries\SDFat/SdFat.h:260: undefined reference to `SdSpiCard::writeBlocks(unsigned long, unsigned char const*, unsigned int)'

C:\Users\ssnover\AppData\Local\Temp\arduino_build_178533\sketch\sdCard.cpp.o: In function `FatFile::setCwd(FatFile*)':

C:\Users\ssnover\Documents\Arduino\libraries\SDFat/FatLib/FatFile.h:803: undefined reference to `FatFile::m_cwd'

C:\Users\ssnover\AppData\Local\Temp\arduino_build_178533\sketch\sdCard.cpp.o: In function `SdFatBase::begin(SdSpiLib*, unsigned char, unsigned char)':

C:\Users\ssnover\Documents\Arduino\libraries\SDFat/SdFat.h:86: undefined reference to `SdSpiCard::begin(SdSpiLib*, unsigned char, unsigned char)'

C:\Users\ssnover\AppData\Local\Temp\arduino_build_178533\sketch\sdCard.cpp.o: In function `FatFileSystem::begin(unsigned char)':

C:\Users\ssnover\Documents\Arduino\libraries\SDFat/FatLib/FatFileSystem.h:43: undefined reference to `FatFile::close()'

C:\Users\ssnover\Documents\Arduino\libraries\SDFat/FatLib/FatFileSystem.h:44: undefined reference to `FatVolume::init(unsigned char)'

C:\Users\ssnover\Documents\Arduino\libraries\SDFat/FatLib/FatFileSystem.h:45: undefined reference to `FatFile::openRoot(FatVolume*)'

C:\Users\ssnover\Documents\Arduino\libraries\SDFat/FatLib/FatFileSystem.h:44: undefined reference to `FatVolume::init(unsigned char)'

C:\Users\ssnover\AppData\Local\Temp\arduino_build_178533\sketch\sdCard.cpp.o: In function `FatFile::exists(char const*)':

C:\Users\ssnover\Documents\Arduino\libraries\SDFat/FatLib/FatFile.h:320: undefined reference to `FatFile::open(FatFile*, char const*, unsigned char)'

C:\Users\ssnover\AppData\Local\Temp\arduino_build_178533\sketch\sdCard.cpp.o: In function `FatFileSystem::mkdir(char const*, bool)':

C:\Users\ssnover\Documents\Arduino\libraries\SDFat/FatLib/FatFileSystem.h:227: undefined reference to `FatFile::mkdir(FatFile*, char const*, bool)'

C:\Users\ssnover\AppData\Local\Temp\arduino_build_178533\sketch\sdCard.cpp.o: In function `FatFileSystem::chdir(char const*, bool)':

C:\Users\ssnover\Documents\Arduino\libraries\SDFat/FatLib/FatFileSystem.h:139: undefined reference to `FatFile::open(FatFile*, char const*, unsigned char)'

C:\Users\ssnover\AppData\Local\Temp\arduino_build_178533\sketch\sdCard.cpp.o: In function `FatFile::exists(char const*)':

C:\Users\ssnover\Documents\Arduino\libraries\SDFat/FatLib/FatFile.h:320: undefined reference to `FatFile::open(FatFile*, char const*, unsigned char)'

collect2.exe: error: ld returned 1 exit status


Admittedly my knowledge on the linking process is lacking, but the top two lines for example confuse me. It appears that despite being able to find the method that matches my arguments, when that method in turn processes the input and calls another one of it's own methods its an undefined reference.

Have I made some error in how I included the files?

phr3ak


CrossRoads

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

ssnover95

Yes, I downloaded the library as a ZIP file just this morning. The file structure of the library is identical to the GitHub repo's file structure starting at src/SdFat.

Go Up