{"action":"created","issue":{"url":"https://api.github.com/repos/queezythegreat/arduino-cmake/issues/22","repository_url":"https://api.github.com/repos/queezythegreat/arduino-cmake","labels_url":"https://api.github.com/repos/queezythegreat/arduino-cmake/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/queezythegreat/arduino-cmake/issues/22/comments","events_url":"https://api.github.com/repos/queezythegreat/arduino-cmake/issues/22/events","html_url":"https://github.com/queezythegreat/arduino-cmake/issues/22","id":3088492,"number":22,"title":"Code using the Arduino SD library fails to link","user":{"login":"nilrog","id":120408,"avatar_url":"https://avatars.githubusercontent.com/u/120408?v=3","gravatar_id":"","url":"https://api.github.com/users/nilrog","html_url":"https://github.com/nilrog","followers_url":"https://api.github.com/users/nilrog/followers","following_url":"https://api.github.com/users/nilrog/following{/other_user}","gists_url":"https://api.github.com/users/nilrog/gists{/gist_id}","starred_url":"https://api.github.com/users/nilrog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nilrog/subscriptions","organizations_url":"https://api.github.com/users/nilrog/orgs","repos_url":"https://api.github.com/users/nilrog/repos","events_url":"https://api.github.com/users/nilrog/events{/privacy}","received_events_url":"https://api.github.com/users/nilrog/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/queezythegreat/arduino-cmake/labels/bug","name":"bug","color":"e10c02"},{"url":"https://api.github.com/repos/queezythegreat/arduino-cmake/labels/fixed","name":"fixed","color":"02e10c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2012-02-03T20:39:53Z","updated_at":"2016-03-21T18:34:21Z","closed_at":"2012-02-28T17:04:45Z","body":"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.\r\n\r\nHere is the error:\r\n\r\nLinking CXX executable sd_cardinfo.elf\r\nCMakeFiles/sd_cardinfo.dir/sd_cardinfo.cpp.obj: In function `SdFile':\r\n/Applications/Arduino.app/Contents/Resources/Java/libraries/SD/utility/SdFat.h:138: undefined reference to `vtable for SdFile'\r\n/Applications/Arduino.app/Contents/Resources/Java/libraries/SD/utility/SdFat.h:138: undefined reference to `vtable for SdFile'\r\nCMakeFiles/sd_cardinfo.dir/sd_cardinfo.cpp.obj: In function `setup':\r\n/Users/nilrog/Documents/Arduino/arduino-cmake/sd_cardinfo/sd_cardinfo.cpp:50: undefined reference to `Sd2Card::init(unsigned char, unsigned char)'\r\nCMakeFiles/sd_cardinfo.dir/sd_cardinfo.cpp.obj: In function `SdVolume::init(Sd2Card*)':\r\n/Applications/Arduino.app/Contents/Resources/Java/libraries/SD/utility/SdFat.h:450: undefined reference to `SdVolume::init(Sd2Card*, unsigned char)'\r\n/Applications/Arduino.app/Contents/Resources/Java/libraries/SD/utility/SdFat.h:450: undefined reference to `SdVolume::init(Sd2Card*, unsigned char)'\r\nCMakeFiles/sd_cardinfo.dir/sd_cardinfo.cpp.obj: In function `SdFile::openRoot(SdVolume&)':\r\n/Applications/Arduino.app/Contents/Resources/Java/libraries/SD/utility/SdFat.h:345: undefined reference to `SdFile::openRoot(SdVolume*)'\r\nCMakeFiles/sd_cardinfo.dir/sd_cardinfo.cpp.obj: In function `setup':\r\n/Users/nilrog/Documents/Arduino/arduino-cmake/sd_cardinfo/sd_cardinfo.cpp:106: undefined reference to `SdFile::ls(unsigned char, unsigned char)'\r\nmake[2]: *** [sd_cardinfo/sd_cardinfo.elf] Error 1\r\nmake[1]: *** [sd_cardinfo/CMakeFiles/sd_cardinfo.dir/all] Error 2\r\n\r\nIf I try the same using one of the EEPROM examples from Arduino the code compiles and links correctly."},"comment":{"url":"https://api.github.com/repos/queezythegreat/arduino-cmake/issues/comments/199416678","html_url":"https://github.com/queezythegreat/arduino-cmake/issues/22#issuecomment-199416678","issue_url":"https://api.github.com/repos/queezythegreat/arduino-cmake/issues/22","id":199416678,"user":{"login":"KoVe","id":4739515,"avatar_url":"https://avatars.githubusercontent.com/u/4739515?v=3","gravatar_id":"","url":"https://api.github.com/users/KoVe","html_url":"https://github.com/KoVe","followers_url":"https://api.github.com/users/KoVe/followers","following_url":"https://api.github.com/users/KoVe/following{/other_user}","gists_url":"https://api.github.com/users/KoVe/gists{/gist_id}","starred_url":"https://api.github.com/users/KoVe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KoVe/subscriptions","organizations_url":"https://api.github.com/users/KoVe/orgs","repos_url":"https://api.github.com/users/KoVe/repos","events_url":"https://api.github.com/users/KoVe/events{/privacy}","received_events_url":"https://api.github.com/users/KoVe/received_events","type":"User","site_admin":false},"created_at":"2016-03-21T18:34:21Z","updated_at":"2016-03-21T18:34:21Z","body":"I get similar errors, but `set(SD_RECURSE True)` doesn't work. I made a small test.\r\n### CMakeLists.txt\r\n`cmake_minimum_required(VERSION 2.8.4)`\r\n`set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/ArduinoToolchain.cmake)`\r\n`set(PROJECT_NAME SDtest)`\r\n`project(${PROJECT_NAME})`\r\n` `\r\n`set(${CMAKE_PROJECT_NAME}_ARDLIBS SD)`\r\n`set(${CMAKE_PROJECT_NAME}_SKETCH SDtest.ino)`\r\n`generate_arduino_firmware(${CMAKE_PROJECT_NAME})`\r\n### SDtest.ino\r\n`#include <Arduino.h>`\r\n`#include <SD.h>`\r\n`void setup() {`\r\n`    SD.begin(4);`\r\n`}`\r\n`void loop() {}`\r\n### Messages:\r\n`[ 97%] Linking CXX executable SDtest.elf`\r\n`libuno_SD.a(Sd2Card.cpp.obj): In function `SPIClass::endTransaction()':`\r\n`/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src/SPI.h:275: undefined reference to `SPIClass::interruptMode'``\r\n`/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src/SPI.h:275: undefined reference to `SPIClass::interruptSave'`\r\n`libuno_SD.a(Sd2Card.cpp.obj): In function `SPIClass::beginTransaction(SPISettings)':`\r\n/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src/SPI.h:179: undefined reference to `SPIClass::interruptMode'\r\n/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src/SPI.h:184: undefined reference to `SPIClass::interruptMode'\r\n/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src/SPI.h:185: undefined reference to `SPIClass::interruptSave'\r\n/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src/SPI.h:186: undefined reference to `SPIClass::interruptMask'\r\n/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src/SPI.h:191: undefined reference to `SPIClass::interruptSave'\r\nlibuno_SD.a(Sd2Card.cpp.obj): In function `SPIClass::endTransaction()':\r\n/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src/SPI.h:269: undefined reference to `SPIClass::interruptMode'\r\nlibuno_SD.a(Sd2Card.cpp.obj): In function `Sd2Card::init(unsigned char, unsigned char)':\r\n/Applications/Arduino.app/Contents/Java/libraries/SD/src/utility/Sd2Card.cpp:268: undefined reference to `SPIClass::begin()'\r\nlibuno_SD.a(Sd2Card.cpp.obj): In function `SPIClass::endTransaction()':\r\n/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI/src/SPI.h:269: undefined reference to `SPIClass::interruptMode'\r\ncollect2: error: ld returned 1 exit status\r\nmake[3]: *** [SDtest.elf] Error 1\r\nmake[2]: *** [CMakeFiles/SDtest.dir/all] Error 2\r\nmake[1]: *** [CMakeFiles/SDtest.dir/rule] Error 2\r\nmake: *** [SDtest] Error 2\r\n\r\nWith the arduino IDE it compiles and links correctly. Any idea what is happening?"}}