queezythegreat/arduino-cmake — Issue #22: Code using the Arduino SD library fails to link
Author: nilrog
Created: 2012-02-03 20:39:53+00:00
State: open

I just made a quick test to see if this tool was useful and not since I really want to get rid of the Arduino IDE but still be able to use all the libraries out there. So I simply created a target using the CardInfo example from the SD library included with Arduino 1.0 (and adding the Arduino.h include to the file). But the code won't link correctly, most likely because the SD library has code also in a subdirectory called "utility" which I guess your cmake tool cannot detect.

Here is the error:

Linking CXX executable sd_cardinfo.elf
CMakeFiles/sd_cardinfo.dir/sd_cardinfo.cpp.obj: In function `SdFile':
/Applications/Arduino.app/Contents/Resources/Java/libraries/SD/utility/SdFat.h:138: undefined reference to `vtable for SdFile'
/Applications/Arduino.app/Contents/Resources/Java/libraries/SD/utility/SdFat.h:138: undefined reference to `vtable for SdFile'
CMakeFiles/sd_cardinfo.dir/sd_cardinfo.cpp.obj: In function `setup':
/Users/nilrog/Documents/Arduino/arduino-cmake/sd_cardinfo/sd_cardinfo.cpp:50: undefined reference to `Sd2Card::init(unsigned char, unsigned char)'
CMakeFiles/sd_cardinfo.dir/sd_cardinfo.cpp.obj: In function `SdVolume::init(Sd2Card*)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/SD/utility/SdFat.h:450: undefined reference to `SdVolume::init(Sd2Card*, unsigned char)'
/Applications/Arduino.app/Contents/Resources/Java/libraries/SD/utility/SdFat.h:450: undefined reference to `SdVolume::init(Sd2Card*, unsigned char)'
CMakeFiles/sd_cardinfo.dir/sd_cardinfo.cpp.obj: In function `SdFile::openRoot(SdVolume&)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/SD/utility/SdFat.h:345: undefined reference to `SdFile::openRoot(SdVolume*)'
CMakeFiles/sd_cardinfo.dir/sd_cardinfo.cpp.obj: In function `setup':
/Users/nilrog/Documents/Arduino/arduino-cmake/sd_cardinfo/sd_cardinfo.cpp:106: undefined reference to `SdFile::ls(unsigned char, unsigned char)'
make[2]: *** [sd_cardinfo/sd_cardinfo.elf] Error 1
make[1]: *** [sd_cardinfo/CMakeFiles/sd_cardinfo.dir/all] Error 2

If I try the same using one of the EEPROM examples from Arduino the code compiles and links correctly.