Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arduino Yún Bridge library conflicts with SD library #1942

Closed
projectgus opened this issue Mar 20, 2014 · 2 comments
Closed

Arduino Yún Bridge library conflicts with SD library #1942

projectgus opened this issue Mar 20, 2014 · 2 comments
Assignees

Comments

@projectgus
Copy link
Contributor

Here's an example sketch that demonstrates the problem on 1.5.6r2:

#include <Bridge.h>
#include <SPI.h>
#include <SD.h>

void setup() {  }
void loop() {  }

Pressing "Verify" fails. At link time there are multiple definitions of the File class found:

/tmp/build4707850354691374642.tmp/SD/SD.cpp.o: In function `callback_makeDirPath(SdFile&, char*, unsigned char, void*)':
/usr/local/share/arduino-1.5.6/libraries/SD/src/SD.cpp:257: multiple definition of `File::rewindDirectory()'
/tmp/build4707850354691374642.tmp/Bridge/FileIO.cpp.o:/usr/local/share/arduino-1.5.6/libraries/Bridge/src/FileIO.cpp:27: first defined here
/tmp/build4707850354691374642.tmp/SD/SD.cpp.o: In function `callback_makeDirPath(SdFile&, char*, unsigned char, void*)':
/usr/local/share/arduino-1.5.6/libraries/SD/src/SD.cpp:257: multiple definition of `File::openNextFile(unsigned char)'
(and so on in a similar fashion.)

Perhaps it's not a very important bug as most people will use the Yún's onboard SD card, but it's a special case for any library which includes SD (even if the sketch doesn't use the SD features.) Also it'd be nice to be able to have dual SD cards, one on a shield and one via the Yún!

The only API-compatible solution I can think of would involve File becoming an abstract base class, with SDFile and BridgeFile implementation. Though this is probably undesirable as it will add quite a few virtual method calls. I haven't looked into it more closely than that, sorry.

@projectgus
Copy link
Contributor Author

This is the best workaround I can come up with for a library which uses SD library functions. This way it should support either an SPI-connected SD or a Bridged SD, depending on which library headers are included into the sketch.

freetronics/FTOLED@7f4476f

I'd love to hear if there's a better solution though, as this is kind of fiddly..

@sandeepmistry
Copy link
Contributor

I just tried the sketch above with IDE 1.6.9, no more linker errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants