Arduino IDE can't compile for Sparkfun Thing when I2C Library included

I've checked all the troubleshooting pages I can find but nothing like this appears.
I had this project running two years ago, but wanted to update it. Since then, I have a new laptop with Windows 10 and latest IDE. The libraries are the same as were used 2 years ago, except for Blynk.
If I comment out the ADXL345 and I2C libraries, it will compile. The error report mentions the I2C.
I can't even compile for the starter program. See below;

/*
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include <SimpleTimer.h>
#include <ADXL345.h>
#include <I2Cdev.h>

void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}
*/

This is the error log that results from trying to compile this;

Arduino: 1.8.8 (Windows 10), Board: "SparkFun ESP8266 Thing, 80 MHz, Flash, Enabled, 512K (no SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp: In static member function 'static int8_t I2Cdev::readBytes(uint8_t, uint8_t, uint8_t, uint8_t*, uint16_t)':

C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:276:75: error: no matching function for call to 'min(uint8_t&, int)'

for (uint8_t k = 0; k < length; k += min(length, BUFFER_LENGTH)) {

^

C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:276:75: note: candidates are:

In file included from c:\users\capek\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\algorithm:62:0,

from C:\Users\capek\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta2\cores\esp8266/Arduino.h:257,

from C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.h:80,

from C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:46:

c:\users\capek\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algo.h:4226:5: note: template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)

min(initializer_list<_Tp> __l, _Compare __comp)

^

c:\users\capek\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algo.h:4226:5: note: template argument deduction/substitution failed:

C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:276:75: note: mismatched types 'std::initializer_list<_Tp>' and 'unsigned char'

for (uint8_t k = 0; k < length; k += min(length, BUFFER_LENGTH)) {

^

In file included from c:\users\capek\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\algorithm:62:0,

from C:\Users\capek\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta2\cores\esp8266/Arduino.h:257,

from C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.h:80,

from C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:46:

c:\users\capek\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algo.h:4221:5: note: template _Tp std::min(std::initializer_list<_Tp>)

min(initializer_list<_Tp> __l)

^

c:\users\capek\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algo.h:4221:5: note: template argument deduction/substitution failed:

C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:276:75: note: mismatched types 'std::initializer_list<_Tp>' and 'unsigned char'

for (uint8_t k = 0; k < length; k += min(length, BUFFER_LENGTH)) {

^

In file included from c:\users\capek\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\algorithm:61:0,

from C:\Users\capek\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta2\cores\esp8266/Arduino.h:257,

from C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.h:80,

from C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:46:

c:\users\capek\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:239:5: note: template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)

min(const _Tp& __a, const _Tp& __b, _Compare __comp)

^

c:\users\capek\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:239:5: note: template argument deduction/substitution failed:

C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:276:75: note: deduced conflicting types for parameter 'const _Tp' ('unsigned char' and 'int')

for (uint8_t k = 0; k < length; k += min(length, BUFFER_LENGTH)) {

^

In file included from c:\users\capek\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\algorithm:61:0,

from C:\Users\capek\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta2\cores\esp8266/Arduino.h:257,

from C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.h:80,

from C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:46:

c:\users\capek\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:193:5: note: template const _Tp& std::min(const _Tp&, const _Tp&)

min(const _Tp& __a, const _Tp& __b)

^

c:\users\capek\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:193:5: note: template argument deduction/substitution failed:

C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:276:75: note: deduced conflicting types for parameter 'const _Tp' ('unsigned char' and 'int')

for (uint8_t k = 0; k < length; k += min(length, BUFFER_LENGTH)) {

^

exit status 1
Error compiling for board SparkFun ESP8266 Thing.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

/////////////////

I hope someone can help.

Thanks.

Mike

Unlike other cores, ESP8266's min function does not allow you to pass it parameters of different type. The version of the I2Cdev library you're using tries to do just this. Luckily, that bug has since been fixed. So all you need to do is update to the latest version of the library and the error will no longer occur. If you need help with that, let me know and I'll provide instructions.

Pert,

Thanks! Yes, please provide instructions.

Mike

  • Delete C:\Program Files (x86)\Arduino\libraries\I2Cdev
  • Delete C:\Program Files (x86)\Arduino\libraries\ADXL345
  • Download the latest version of the I2Cdev library: https://github.com/jrowberg/i2cdevlib/archive/master.zip
  • Unzip the downloaded file
  • (In the Arduino IDE) Sketch > Include Library > Add .ZIP Library
  • From the unzipped folder, select the i2cdevlib-master/Arduino/I2Cdev folder
  • Click "Open".
  • Sketch > Include Library > Add .ZIP Library
  • From the unzipped folder, select the i2cdevlib-master/Arduino/ADXL345 folder
  • Click "Open".

Note that you should never install libraries to the Arduino IDE installation folder (C:\Program Files (x86)\Arduino in your case). The reason is that anything you install to that location will be lost whenevery you update to a new version of the Arduino IDE. Instead, you should install libraries to the libraries subfolder of your sketchbook folder. The location of the sketchbook folder is shown at File > Preferences > Sketchbook location. The Arduino IDE's Sketch > Include Library > Add .ZIP Library and Sketch > Include Library > Manage Libraries features will automatically install libraries to the correct location so you only need to worry about this when doing a manual library installation.

Reference:

Pert,

All good. Thanks again.

Mike

You're welcome. I'm glad to hear it's working now. Enjoy!
Per