I'm trying to compile a simple I2C example to read data from an MPU-6050 accel/gyro sensor, but I'm getting the compilation error:
/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:27:8: error: 'SPISettings' does not name a type
static SPISettings settings;
^
/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp: In member function 'void Sd2Card::chipSelectHigh()':
/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:167:9: error: 'class SPIClass' has no member named 'endTransaction'
SPI.endTransaction();
^
/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp: In member function 'void Sd2Card::chipSelectLow()':
/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:176:9: error: 'class SPIClass' has no member named 'beginTransaction'
SPI.beginTransaction(settings);
^
/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:176:26: error: 'settings' was not declared in this scope
SPI.beginTransaction(settings);
^
/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp: In member function 'uint8_t Sd2Card::init(uint8_t, uint8_t)':
/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:269:3: error: 'settings' was not declared in this scope
settings = SPISettings(250000, MSBFIRST, SPI_MODE0);
^
/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:269:53: error: 'SPISettings' was not declared in this scope
settings = SPISettings(250000, MSBFIRST, SPI_MODE0);
^
/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:275:7: error: 'class SPIClass' has no member named 'beginTransaction'
SPI.beginTransaction(settings);
^
/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:279:7: error: 'class SPIClass' has no member named 'endTransaction'
SPI.endTransaction();
^
/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp: In member function 'uint8_t Sd2Card::setSckRate(uint8_t)':
/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:518:14: error: 'settings' was not declared in this scope
case 0: settings = SPISettings(25000000, MSBFIRST, SPI_MODE0); break;
^
/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp:518:66: error: 'SPISettings' was not declared in this scope
case 0: settings = SPISettings(25000000, MSBFIRST, SPI_MODE0); break;
^
make: *** [.build_ano/uno/SD/src/utility/Sd2Card.o] Error 1
Make failed with code 2
I've commented-out all code until it compiled without error, and I found that the error is caused by the line:
#include <Wire.h>
So my minimal code to reproduce the error is:
#include <Wire.h>
void setup(){
}
void loop(){
}
Why is this include throwing this error? Why is it trying to compile code for accessing an SD card when I have no code that uses that?
I'm using Arduino 1.6.1 and targeting the Uno. I found I can fix this error by copying version 1.0 of the Wire library into my local sketch folder.
2 Answers 2
If fixed this by deleting this built-in library
/usr/share/arduino/libraries/SD
but then I received the error:
/usr/share/arduino/libraries/Robot_Control/ArduinoRobot.cpp:25:2: error: 'Serial1' was not declared in this scope
Serial1.begin(9600);
so I deleted these libraries as well:
/usr/share/arduino/libraries/Robot_Control
/usr/share/arduino/libraries/Robot_Motor
which appear to be buggy in the 1.6 Arduino release. It's still unclear why any of these libraries were being used, since I wasn't including any of their files.
-
Can you elaborate any further on this? I tried these steps and it still isn't working for me.Andrew– Andrew2017年04月19日 13:36:31 +00:00Commented Apr 19, 2017 at 13:36
Try a later version of the IDE. Try making a completely new sketch (don't just delete things from your current one). It looks to me like it is trying to compile things it shouldn't.
/usr/share/arduino/libraries/SD/src/utility/Sd2Card.cpp
That doesn't seem relevant to your empty sketch.
-
Yes, it's strange, and yes, it's a completely new sketch.Cerin– Cerin2016年05月08日 00:53:53 +00:00Commented May 8, 2016 at 0:53
-
If a sketch containing
#include <Wire.h>
and thenvoid setup(){} void loop(){}
doesn't compile there is something wrong with your installation. That should compile fine. Try IDE 1.6.8.2016年05月08日 07:13:20 +00:00Commented May 8, 2016 at 7:13