SPI library conflict with SD library(or the SPI library have some problems).

Hi everyone, I ran into leet say a problems with a sketch. It use the SD and SPI library and the sketch main function is to flash a chip on a LCD controller board and the firmware is stored on a SD card. I used the lasses 1.6.8 to compile, doesn't work. Then the classic 1.0.x, I works but it kind of like not very well. Then the 1.5.x beta, that baby spit out error all over the places and I don't like that. Please help me!

/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/build6249963415924508699.tmp/SD/utility/SPI.cpp.o: In function `SPIClass::end()':
/private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/93E66254-9881-46B3-8624-B53A79D2B9CA/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/SPI.cpp:34: multiple definition of `SPIClass::begin()'
/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/build6249963415924508699.tmp/SD/SPI.cpp.o:/private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/93E66254-9881-46B3-8624-B53A79D2B9CA/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/SPI.cpp:34: first defined here
/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/build6249963415924508699.tmp/SD/utility/SPI.cpp.o: In function `SPIClass::usingInterrupt(unsigned char)':
/private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/93E66254-9881-46B3-8624-B53A79D2B9CA/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/SPI.cpp:58: multiple definition of `SPIClass::end()'
/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/build6249963415924508699.tmp/SD/SPI.cpp.o:/private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/93E66254-9881-46B3-8624-B53A79D2B9CA/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/SPI.cpp:58: first defined here
/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/build6249963415924508699.tmp/SD/utility/SPI.cpp.o: In function `SPIClass::usingInterrupt(unsigned char)':
/private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/93E66254-9881-46B3-8624-B53A79D2B9CA/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/SPI.cpp:102: multiple definition of `SPIClass::usingInterrupt(unsigned char)'
/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/build6249963415924508699.tmp/SD/SPI.cpp.o:/private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/93E66254-9881-46B3-8624-B53A79D2B9CA/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/SPI.cpp:102: first defined here
/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/build6249963415924508699.tmp/SD/utility/SPI.cpp.o: In function `SPIClass::end()':
/private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/93E66254-9881-46B3-8624-B53A79D2B9CA/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/SPI.cpp:34: multiple definition of `SPIClass::interruptMode'
/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/build6249963415924508699.tmp/SD/SPI.cpp.o:/private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/93E66254-9881-46B3-8624-B53A79D2B9CA/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/SPI.cpp:34: first defined here
/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/build6249963415924508699.tmp/SD/utility/SPI.cpp.o: In function `SPIClass::end()':
/private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/93E66254-9881-46B3-8624-B53A79D2B9CA/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/SPI.cpp:34: multiple definition of `SPIClass::interruptMask'
/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/build6249963415924508699.tmp/SD/SPI.cpp.o:/private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/93E66254-9881-46B3-8624-B53A79D2B9CA/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/SPI.cpp:34: first defined here
/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/build6249963415924508699.tmp/SD/utility/SPI.cpp.o: In function `SPIClass::end()':
/private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/93E66254-9881-46B3-8624-B53A79D2B9CA/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/SPI.cpp:34: multiple definition of `SPIClass::interruptSave'
/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/build6249963415924508699.tmp/SD/SPI.cpp.o:/private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/93E66254-9881-46B3-8624-B53A79D2B9CA/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/SPI.cpp:34: first defined here
/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/build6249963415924508699.tmp/SD/utility/SPI.cpp.o: In function `SPIClass::end()':
/private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/93E66254-9881-46B3-8624-B53A79D2B9CA/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/SPI.cpp:34: multiple definition of `SPI'
/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/build6249963415924508699.tmp/SD/SPI.cpp.o:/private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/93E66254-9881-46B3-8624-B53A79D2B9CA/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/SPI.cpp:34: first defined here
collect2: error: ld returned 1 exit status
Error compiling.

I downloaded the code on this GitHub page:https://github.com/adafruit/Adafruit_RTD266X_I2CFlasher

SD/utility/SPI.cpp.o: In function `SPIClass::end()':
SD/src/utility/SPI.cpp:34: multiple definition of `SPI'
SD/src/SPI.cpp:34: first defined here

You seem to have many extra copies of SPI.cpp sitting in your SD library. My copy of the SD library from Arduino 1.6.12 doesn't have ANY of those three copies of SPI.cpp! I think your installation is corrupted and you should re-install the Arduino IDE. Be sure to rename or delete the Arduino15 directory before you re-install:

A bunch of people have had IDE 1.6.x problems, including IDE crashes and bizarre compile errors, when they had a previous 1.5.x/1.6.x installation. At least some of those problems seem to be caused by incompatible executables and preference files that the IDE saves outside the IDE installation directory. Perhaps that is what is causing your particular problem. In such cases it appears that the fix is to delete or rename the old "Arduino15" directory and re-install 1.6.x.

On Mac OS X: /Users/(username)/Library/Arduino15 (a.k.a. ~/Library/Arduino15) (Note: The 'Library' folder is greyed out in Finder. The folder can't be opened with a double-click. To browse the contents of 'Library', ctrl-click on it and select "Open in New Tab" from the pop-up menu.)

On Windows delete or rename both: Arduino IDE 1.6.5r5 and previous: C:\Users(username)\AppData\Roaming\Arduino15 Arduino IDE 1.6.6 and later: C:\Users(username)\AppData\Local\Arduino15

On Linux: /home/(username)/.arduino15 (a.k.a. ~/.arduino15) (Note: file/folder names starting with '.' are not normally shown in directory listings. Use 'ls -a' to get a directory listing that includes the hidden files.)

I tried and it gave me this:

/private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/B34CE17A-121B-495E-8265-7BD34BD8102C/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/Sd2Card.cpp:27:8: error: 'SPISettings' does not name a type static SPISettings settings; ^ /private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/B34CE17A-121B-495E-8265-7BD34BD8102C/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/Sd2Card.cpp: In member function 'void Sd2Card::chipSelectHigh()': /private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/B34CE17A-121B-495E-8265-7BD34BD8102C/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/Sd2Card.cpp:163:7: error: 'class SPIClass' has no member named 'endTransaction' SPI.endTransaction(); ^ /private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/B34CE17A-121B-495E-8265-7BD34BD8102C/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/Sd2Card.cpp: In member function 'void Sd2Card::chipSelectLow()': /private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/B34CE17A-121B-495E-8265-7BD34BD8102C/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/Sd2Card.cpp:169:7: error: 'class SPIClass' has no member named 'beginTransaction' SPI.beginTransaction(settings); ^ /private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/B34CE17A-121B-495E-8265-7BD34BD8102C/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/Sd2Card.cpp:169:24: error: 'settings' was not declared in this scope SPI.beginTransaction(settings); ^ /private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/B34CE17A-121B-495E-8265-7BD34BD8102C/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/Sd2Card.cpp: In member function 'uint8_t Sd2Card::init(uint8_t, uint8_t)': /private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/B34CE17A-121B-495E-8265-7BD34BD8102C/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/Sd2Card.cpp:261:3: error: 'settings' was not declared in this scope settings = SPISettings(250000, MSBFIRST, SPI_MODE0); ^ /private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/B34CE17A-121B-495E-8265-7BD34BD8102C/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/Sd2Card.cpp:261:53: error: 'SPISettings' was not declared in this scope settings = SPISettings(250000, MSBFIRST, SPI_MODE0); ^ /private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/B34CE17A-121B-495E-8265-7BD34BD8102C/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/Sd2Card.cpp:267:7: error: 'class SPIClass' has no member named 'beginTransaction' SPI.beginTransaction(settings); ^ /private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/B34CE17A-121B-495E-8265-7BD34BD8102C/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/Sd2Card.cpp:271:7: error: 'class SPIClass' has no member named 'endTransaction' SPI.endTransaction(); ^ /private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/B34CE17A-121B-495E-8265-7BD34BD8102C/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/Sd2Card.cpp: In member function 'uint8_t Sd2Card::setSckRate(uint8_t)': /private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/B34CE17A-121B-495E-8265-7BD34BD8102C/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/Sd2Card.cpp:510:14: error: 'settings' was not declared in this scope case 0: settings = SPISettings(25000000, MSBFIRST, SPI_MODE0); break; ^ /private/var/folders/rt/yw784lfj27g_cb1mwxrhhc900000gn/T/AppTranslocation/B34CE17A-121B-495E-8265-7BD34BD8102C/d/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/Sd2Card.cpp:510:66: error: 'SPISettings' was not declared in this scope case 0: settings = SPISettings(25000000, MSBFIRST, SPI_MODE0); break; ^ Error compiling.

Looks like it finds the wrong version of SPI.h. Have you got a copy of SPI.h in your sketch folder? Is there a third-party library in your Libraries folder called SPI? Does your sketch include SPI.h before SD.h like it should?

Hi, I don’t have any “third-party” SPI version installed in my IDE. Can you please upload the SPI.h and SPI.cpp that you are using?

It looks like your problem is too many copies of SPI.h already. I don't think that having me send you another is going to help.

If you go to "Arduino->Preferences..." and turn on: "Show verbose output during: [X] compilation [ ] upload" then the messages SHOULD say what files are being included in your build. Perhaps that will point to a copy of SPI.h that you didn't know about.

The last resort would be for you to send me the sketch or point to where I can download it. I could then try to build it on my machine. If it works, we know the problem is in your Arduino installation and we can work to fix that. If it doesn't work I can figure out why and tell you what is going wrong.

From the logs it appears that your Arduino IDE is being translocated for security. This happens if you run an app from a downloaded disk image or from the same directory where you unpacked it from a downloaded ZIP archive. Try moving the Arduino.app to your Applications directory before opening it to see if that might possibly be an issue.

Hi, sorry for the late reply, I tried download a fresh version of the 1.5 IDE and move it to /Application and it gave me this: /Applications/Arduino.app/Contents/Resources/Java/libraries/SD/src/utility/Sd2Card.cpp:26:17: fatal error: SPI.h: No such file or directory

include

^ compilation terminated. Error compiling.

Like I said, I tried on 1.6 and it work but it gave me nothing in the serial monitor and in 1.0, it compile and upload to the board but it won't work like in 1.6.

Place to download:https://github.com/adafruit/Adafruit_RTD266X_I2CFlasher