undefined gmtime() reference.....

Hi All,

I'm trying to compile the ThingPulse Color Weather Station code, available here.

This code is generating an error:

String getTime(time_t *timestamp) {
struct tm *timeInfo = gmtime(timestamp);

char buf[6];
sprintf(buf, "%02d:%02d", timeInfo->tm_hour, timeInfo->tm_min);
return String(buf);
}

The error is:

Arduino: 1.8.1 (Windows 7), Board: "NodeMCU 1.0 (ESP-12E Module), 160 MHz, 115200, 4M (3M SPIFFS)"

sketch\esp8266-weather-station-color.ino.cpp.o: In function `drawAbout()':

C:\Users\Adm\Documents\Arduino\esp8266-weather-station-color\esp8266-weather-station-color/esp8266-weather-station-color.ino:611: undefined reference to `gmtime'

sketch\esp8266-weather-station-color.ino.cpp.o: In function `getTime(long*)':

C:\Users\Adm\Documents\Arduino\esp8266-weather-station-color\esp8266-weather-station-color/esp8266-weather-station-color.ino:611: undefined reference to `gmtime'

libraries\ESP8266_Weather_Station\OpenWeatherMapForecast.cpp.o:(.text._ZN22OpenWeatherMapForecast5valueE6String+0x9e): undefined reference to `gmtime'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

So, it seems to be saying that the function 'gmtime()' is not being found?? How do I solve this issue?

Thanks,

John

(deleted)

Yes, I appear to have all the necessary libraries installed. Moreover, I have built this same basic project about a year ago, but the supported weather data source changed, so I needed to update the project with the new weather API information. I haven't been able to get this new code compiled.

Please do this:

  • (In the Arduino IDE) click File > Preferences
  • Check the box next to "Show verbose output during: > compilation
  • Click "OK"
  • Sketch > Verify/Compile
  • After the compilation fails you'll see a button on the right side of the orange bar "Copy error messages". Click that button.
  • In a forum reply here, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
  • Press "Ctrl + V". This will paste the compilation output between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.

If the length of the output exceeds the forum's 9000 character limit, save it in a .txt file and post it here as an attachment. If you click the "Reply" button you'll see the "Attachments and other options" link.

Hi,

OK, here is the verbose error messaging from the failed compile as an attachment

Thanks,

John

Compile Output.txt (59.2 KB)

The problem is that you're using an extremely outdated version of ESP8266 core for Arduino. Please do this:

  • Tools > Board > Boards Manager
  • Wait for the download to finish.
  • Scroll down through the available packages until you see "esp8266 by ESP8266 Community". Click on it.
  • Click "Update".
  • Wait for the update to finish.
  • Click "Close".

After updating to the modern version of ESP8266 core for Arduino, your code should now compile.

pert:
The problem is that you're using an extremely outdated version of ESP8266 core for Arduino.

After updating to the modern version of ESP8266 core for Arduino, your code should now compile.

Hi,

Thanks! That did the trick!

John

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