Strange issue compiling for esp8266 platform

Hey... hope you can help me

got a pretty small sketch to read tim from rtc connected to a wemos d1 mini.
// Date and time functions using a DS3231 RTC connected via I2C and Wire lib
#include "RTClib.h"

RTC_DS3231 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup () {
Serial.begin(115200);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
abort();
}
DateTime now = rtc.now();
// January 17, 2022 at 9pm, 51min you would call:
// rtc.adjust(DateTime(2022, 1, 17, 21, 51, 0));
// to add 30 seconds call:
// rtc.adjust(DateTime(now.unixtime() +30));
}

void loop () {
DateTime now = rtc.now();

Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" (");
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(") ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();

Serial.print(" since midnight 1/1/1970 = ");
Serial.print(now.unixtime());
Serial.print("s = ");
Serial.print(now.unixtime() / 86400L);
Serial.println("d");

// calculate a date which is 7 days, 12 hours, 30 minutes, 6 seconds into the future
DateTime future (now + TimeSpan(7, 12, 30, 6));

Serial.print(" now + 7d + 12h + 30m + 6s: ");
Serial.print(future.year(), DEC);
Serial.print('/');
Serial.print(future.month(), DEC);
Serial.print('/');
Serial.print(future.day(), DEC);
Serial.print(' ');
Serial.print(future.hour(), DEC);
Serial.print(':');
Serial.print(future.minute(), DEC);
Serial.print(':');
Serial.print(future.second(), DEC);
Serial.println();

Serial.print("Temperature: ");
Serial.print(rtc.getTemperature());
Serial.println(" C");

Serial.println();
delay(1000);
}

it works on several AVR-Boards even on espp32 boards. on each esp8255 board it causes lots of errors, I delete and reanstall all esp8266 boards on the 2.3.2 IDE. even deleted and reinstall the whole package-directory in \arduino15....
heres the last part of error-message:

d:\Arduino\portable\sketchbook\libraries\SPI\SPI.cpp: In member function 'void SPIClass::setFrequency(uint32_t)':
d:\Arduino\portable\sketchbook\libraries\SPI\SPI.cpp:263:38: error: call of overloaded 'abs(uint32_t)' is ambiguous
263 | if(abs(freq - calFreq) < abs(freq - bestFreq)) {
| ^
In file included from c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\cstdlib:75,
from c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\stdlib.h:36,
from C:\Users\newbi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Arduino.h:27,
from d:\Arduino\portable\sketchbook\libraries\SPI\SPI.h:24,
from d:\Arduino\portable\sketchbook\libraries\SPI\SPI.cpp:22:
c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\stdlib.h:74:5: note: candidate: 'int abs(int)'
74 | int abs (int);
| ^~~
In file included from c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\cstdlib:77,
from c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\stdlib.h:36,
from C:\Users\newbi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Arduino.h:27,
from d:\Arduino\portable\sketchbook\libraries\SPI\SPI.h:24,
from d:\Arduino\portable\sketchbook\libraries\SPI\SPI.cpp:22:
c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
d:\Arduino\portable\sketchbook\libraries\SPI\SPI.cpp:263:61: error: call of overloaded 'abs(uint32_t)' is ambiguous
263 | if(abs(freq - calFreq) < abs(freq - bestFreq)) {
| ^
In file included from c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\cstdlib:75,
from c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\stdlib.h:36,
from C:\Users\newbi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Arduino.h:27,
from d:\Arduino\portable\sketchbook\libraries\SPI\SPI.h:24,
from d:\Arduino\portable\sketchbook\libraries\SPI\SPI.cpp:22:
c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\stdlib.h:74:5: note: candidate: 'int abs(int)'
74 | int abs (int);
| ^~~
In file included from c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\cstdlib:77,
from c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\stdlib.h:36,
from C:\Users\newbi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Arduino.h:27,
from d:\Arduino\portable\sketchbook\libraries\SPI\SPI.h:24,
from d:\Arduino\portable\sketchbook\libraries\SPI\SPI.cpp:22:
c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
c:\users\newbi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
Mehrere Bibliotheken wurden für "Wire.h" gefunden
Benutzt: D:\Arduino\portable\sketchbook\libraries\Wire
Nicht benutzt: C:\Users\newbi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\Wire
Mehrere Bibliotheken wurden für "SPI.h" gefunden
Benutzt: D:\Arduino\portable\sketchbook\libraries\SPI
Nicht benutzt: C:\Users\newbi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\SPI
Bibliothek RTClib in Version 2.1.3 im Ordner: D:\Arduino\portable\sketchbook\libraries\RTClib wird verwendet
Bibliothek Adafruit BusIO in Version 1.15.0 im Ordner: D:\Arduino\portable\sketchbook\libraries\Adafruit_BusIO wird verwendet
Bibliothek Wire in Version 1.0 im Ordner: D:\Arduino\portable\sketchbook\libraries\Wire wird verwendet
Bibliothek SPI in Version 1.0 im Ordner: D:\Arduino\portable\sketchbook\libraries\SPI wird verwendet
exit status 1

Compilation error: exit status 1

I don't see that behaviour here when I compile your sketch for a D1 mini. Even with the warning level cranked up, all I get is a warning about an unused variable.

Here's the results I see, properly enclosed with the <CODE/> tool, as your sketch and errors should have been:

arduino-cli compile -b esp8266:esp8266:d1_mini:xtal=80,vt=flash,exception=legacy,ssl=all,eesz=4M2M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=460800 --warnings all --output-dir /home/me/tmp --no-color (in directory: /home/me/Documents/sketchbook/Wemos_D1_mini/test)
/home/me/Documents/sketchbook/Wemos_D1_mini/test/test.ino: In function 'void setup()':
/home/me/Documents/sketchbook/Wemos_D1_mini/test/test.ino:15:10: warning: variable 'now' set but not used [-Wunused-but-set-variable]
 DateTime now = rtc.now();
          ^
Executable segment sizes:
IROM   : 237444          - code in flash         (default or ICACHE_FLASH_ATTR)
IRAM   : 27688   / 32768 - code in IRAM          (ICACHE_RAM_ATTR, ISRs...)
DATA   : 1344  )         - initialized variables (global, static) in RAM/HEAP
RODATA : 808   ) / 81920 - constants             (global, static) in RAM/HEAP
BSS    : 25384 )         - zeroed variables      (global, static) in RAM/HEAP
Sketch uses 267284 bytes (25%) of program storage space. Maximum is 1044464 bytes.
Global variables use 27536 bytes (33%) of dynamic memory, leaving 54384 bytes for local variables. Maximum is 81920 bytes.
Used library   Version Path
RTClib         2.1.4   /home/me/Documents/sketchbook/libraries/RTClib
Adafruit BusIO 1.16.0  /home/me/Documents/sketchbook/libraries/Adafruit_BusIO
Wire           1.0     /home/me/.arduino15/packages/esp8266/hardware/esp8266/2.6.3/libraries/Wire
SPI            1.0     /home/me/.arduino15/packages/esp8266/hardware/esp8266/2.6.3/libraries/SPI
Used platform   Version Path
esp8266:esp8266 2.6.3   /home/me/.arduino15/packages/esp8266/hardware/esp8266/2.6.3
Compilation finished successfully.

Now, it's entirely possible that the current ESP8266 core is throwing the errors you're seeing. I haven't updated mine in donkey's years because I found that code that worked perfectly fine with an older core failed mysteriously with newer ones. Something to think about.

Hi @mkuester.

I see you have installed a standalone copy of the "SPI" library. The "SPI" library is very architecture specific. For this reason, the boards platform of each architecture provides its own "platform bundled" variant of the library, tailored to the microcontrollers of that platform, as well as to the specific version of the platform it is bundled with.

Normally, the "platform bundled" library would be used, but the presence of another installation of the library under your sketchbook folder causes that library to be used instead. It seems that the version of the library you installed is not compatible with the ESP8266 boards platform, which caused the compilation error.

Installation of a copy of the "SPI" library under your sketchbook might be reasonable for certain advanced use cases, but otherwise it is a bad idea. So if you don't have a specific valid reason for having installed the "SPI" library there then you should remove it by deleting the folder at the following path on your hard drive:

d:\Arduino\portable\sketchbook\libraries\SPI

:warning: Please be careful when deleting things from your computer. When in doubt, back up!

If you did have a specific valid reason for installing the library there, we can advise you on an alternative solution, but we would first need you to provide a detailed description of why you did this thing.

1 Like

Oho, I missed that; good catch! That would have been much easier to see if the <CODE/> tool had been used. There's also an extra Wire library in there as well.

1 Like

@mkuester the same recommendation applies to the Wire library. Even if it doesn't happen to cause problems now, it might do so in the future. So unless you had a very good reason for installing it there, remove it:

D:\Arduino\portable\sketchbook\libraries\Wire

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.