Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile error with AsyncStaticWebHandler sonoff-debug #6

Closed
xoseperez opened this issue Nov 29, 2016 · 19 comments
Closed

Compile error with AsyncStaticWebHandler sonoff-debug #6

xoseperez opened this issue Nov 29, 2016 · 19 comments

Comments

@xoseperez
Copy link
Owner

Originally reported by: an_indian_man (Bitbucket: an_indian_man, GitHub: Unknown)


pio run -e sonoff-debug
Win10 x64
platformIO
ESP-stage

.piolibdeps\ESPAsyncWebServer_ID306\src\WebHandlers.cpp: In member function 'AsyncStaticWebHandler& AsyncStaticWebHandler::setLastModified(tm*)':
.piolibdeps\ESPAsyncWebServer_ID306\src\WebHandlers.cpp:67:64: error: 'strftime' was not declared in this scope
strftime (result,30,"%a, %d %b %Y %H:%M:%S %Z", last_modified);
^
.piolibdeps\ESPAsyncWebServer_ID306\src\WebHandlers.cpp: In member function 'AsyncStaticWebHandler& AsyncStaticWebHandler::setLastModified(time_t)':
.piolibdeps\ESPAsyncWebServer_ID306\src\WebHandlers.cpp:72:60: error: 'gmtime' was not declared in this scope
return setLastModified((struct tm *)gmtime(&last_modified));
^
.piolibdeps\ESPAsyncWebServer_ID306\src\WebHandlers.cpp: In member function 'AsyncStaticWebHandler& AsyncStaticWebHandler::setLastModified()':
.piolibdeps\ESPAsyncWebServer_ID306\src\WebHandlers.cpp:77:25: error: 'time' was not declared in this scope
if(time(&last_modified) == 0) //time is not yet set

@xoseperez
Copy link
Owner Author

Original comment by an_indian_man (Bitbucket: an_indian_man, GitHub: Unknown):


I have tried to add time.h to config and added to the all.h

@xoseperez
Copy link
Owner Author

Original comment by an_indian_man (Bitbucket: an_indian_man, GitHub: Unknown):


Fixed:

platform changed to espressif8266_stage for sonoff-debug

#!arduino

[env:sonoff-debug]
platform = espressif8266_stage
framework = arduino
lib_deps = ${common.lib_deps}
extra_script = pio_hooks.py
board = esp01_1m
build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF
lib_ignore = FauxmoESP

@xoseperez
Copy link
Owner Author

I cannot reproduce the error using the stable version of the platform (i.e. platform = espressif8266). Can you check what version of ESPAsyncWebServer you have doing a pio lib list?

@xoseperez
Copy link
Owner Author

Original comment by an_indian_man (Bitbucket: an_indian_man, GitHub: Unknown):


ea7b76b0ee

@xoseperez
Copy link
Owner Author

Original comment by an_indian_man (Bitbucket: an_indian_man, GitHub: Unknown):


a fresh pull from your source still produces the same results.

@xoseperez
Copy link
Owner Author

Could it be an old esp8266 arduino core? Check this: me-no-dev/ESPAsyncWebServer#60. Also: me-no-dev/ESPAsyncWebServer#96. Can you update (pio platform update)?

@xoseperez
Copy link
Owner Author

Original comment by an_indian_man (Bitbucket: an_indian_man, GitHub: Unknown):


its a brand new install, i will try it though.

@xoseperez
Copy link
Owner Author

Original comment by an_indian_man (Bitbucket: an_indian_man, GitHub: Unknown):


all up to date

@xoseperez
Copy link
Owner Author

Do you have the same issue compiling the example from ESPAsyncWebServer library?

@xoseperez
Copy link
Owner Author

Original comment by an_indian_man (Bitbucket: an_indian_man, GitHub: Unknown):


I'll give that a go when I get home.

@xoseperez
Copy link
Owner Author

Original comment by Pavel Eremin (Bitbucket: paveleremin, GitHub: paveleremin):


same issue
123.JPG

from pio lib list

ESPAsyncWebServer
=================
#ID: 306
Asynchronous HTTP and WebSocket Server Library for ESP8266 and ESP32

Keywords: async, websocket, http, webserver
Compatible frameworks: arduino
Compatible platforms: espressif8266
Authors: Hristo Gochkov

When I changed espressif8266 to espressif8266_statge in platformio.ini I got SUCCESS. Is it ok?

@xoseperez
Copy link
Owner Author

Original comment by Lars (Bitbucket: R4cer, GitHub: Unknown):


I had the same problem, also on Win10 x64.
Using the _stage platform solved the problem for me. My Sonoff devices are working fine.

@xoseperez
Copy link
Owner Author

It looks like a race condition between the core time.h library used in WebHandlerImpl.h of ESPAsyncWebServerand the Time.h library used by NtpClientLib in windows machines.

Check issue 2341 in Arduino Core for ESP8266 and issue 60 in ESPAsyncWebServer.

Maybe some of you can test @kiralikbeyin workaround:

  1. Make a copy of time.h and name it to "_time.h" in /Library/Arduino15/packages/esp8266/tools/xtensa-l1. x106-elf-gcc/1.20.0-26-gb404fb9-2/xtensa-lx106-elf/include
  2. replace in #include <time.h> to #include <_time.h> WebHandlerImpl.h in ESPAsyncWebServer library

@xoseperez
Copy link
Owner Author

@R4CER @an_indian_man @paveleremin Have any of you tested this solution? Can you report back?

@xoseperez
Copy link
Owner Author

Original comment by Pavel Eremin (Bitbucket: paveleremin, GitHub: paveleremin):


@xoseperez where folder "/Library/Arduino15/" is located? I'm not familiar with C++ but I can try... Also want to ask: what it's mean:
23.JPG
This bug was fixed or detected in 1.4.0 version?

@xoseperez
Copy link
Owner Author

Original comment by an_indian_man (Bitbucket: an_indian_man, GitHub: Unknown):


I'll repull the tree and flash some new devices tonight.

@xoseperez
Copy link
Owner Author

Version 1.4.3 uses a forked version of the Time library by Paul Stoffregen (here: https://github.com/xoseperez/Time) that deletes the otherwise unneeded Time.h file and prevents the conflict with the core time.h file in windows machines.
If you are using PlatformIO remove the ".piolibdeps/Time_ID44" folder and build the project again. If using Arduino download the ZIP file from the forked repo (https://github.com/xoseperez/Time) and install it in your IDE using the "Add .ZIP Library" option.

@xoseperez
Copy link
Owner Author

Tested under windows with latest version.

@igrowing
Copy link

igrowing commented Dec 8, 2018

This compilation problem happens in Windows only. Linux and Mac are case sensitive for files, so these OSes differ between time.h and Time.h. Windows doesn't.
The problem comes when Time_ID44 lib in installed (that's often used lib) and ESPAsyncWebServer_ID306 lib includes time.h in WebHandlerImpl.h.
So wrong time lib is included due to OS case insensitivity.
There is advice to include TimeLib.h instead of time.h. Tried this, doesn't work.
Workaround that works:

  1. Rename the lib:
  • Go to: drive:\Users\username\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include
  • Rename time.h to _time.h.
  1. Find all occurrences of WebHandlerImpl.h in your Windows. Replace #include <time.h> with #include <_time.h>
  2. Build your project. (Recommended restart platformio before the build).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants