PlatformIO Community

ESP32 basicOTA won't compile

Hi, I have problem that I couldn’t find any solution or whatsoever on google. So I will ask here. So basiclly I want to upload basicOTA example from Platformio library example for Esp32. I tried example from Arduino editor and it works fine. But in platformio same code with same libraries won’t compile.
I checked compiler standard and it is c++11, installed ArduinoOTA library globaly and specific to project and still wont compile, below is compiler output. Thank you soo much for any help, I would really appreciate it! I forgot, board is DOIT Esp32

Archiving .pio\build\esp32doit-devkit-v1\lib7af\libSD.a

src\main.cpp: In function ‘void setup()’:
src\main.cpp:35:6: error: ‘class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>’ has no member named ‘onStart’
.onStart( {
^
src\main.cpp: In lambda function:
src\main.cpp:37:22: error: ‘class ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>’ has no member named ‘getCommand’
if (ArduinoOTA.getCommand() == U_FLASH)
^
src\main.cpp:37:38: error: ‘U_FLASH’ was not declared in this scope
if (ArduinoOTA.getCommand() == U_FLASH)
^
src\main.cpp: In function ‘void setup()’:
src\main.cpp:51:17: error: ‘ota_error_t’ has not been declared
.onError([](ota_error_t error) {
^
src\main.cpp: In lambda function:
src\main.cpp:53:20: error: ‘OTA_AUTH_ERROR’ was not declared in this scope
if (error == OTA_AUTH_ERROR) Serial.println(“Auth Failed”);
^
src\main.cpp:54:25: error: ‘OTA_BEGIN_ERROR’ was not declared in this scope
else if (error == OTA_BEGIN_ERROR) Serial.println(“Begin Failed”);
^
src\main.cpp:55:25: error: ‘OTA_CONNECT_ERROR’ was not declared in this scope
else if (error == OTA_CONNECT_ERROR) Serial.println(“Connect Failed”);
^
src\main.cpp:56:25: error: ‘OTA_RECEIVE_ERROR’ was not declared in this scope
else if (error == OTA_RECEIVE_ERROR) Serial.println(“Receive Failed”);
^
src\main.cpp:57:25: error: ‘OTA_END_ERROR’ was not declared in this scope
else if (error == OTA_END_ERROR) Serial.println(“End Failed”);
^
src\main.cpp: In function ‘void setup()’:
src\main.cpp:60:20: error: no matching function for call to ‘ArduinoOTAMdnsClass<WiFiServer, WiFiClient, WiFiUDP>::begin()’
ArduinoOTA.begin();
^
In file included from src\main.cpp:5:0:
C:/Users/lesko/.platformio/lib/ArduinoOTA_ID6178/src/ArduinoOTA.h:91:8: note: candidate: void ArduinoOTAMdnsClass<NetServer, NetClient, NetUDP>::begin(IPAddress, const char*, const char*, OTAStorage&) [with NetServer = WiFiServer; NetClient = WiFiClient; NetUDP = WiFiUDP]
void begin(IPAddress localIP, const char* name, const char* password, OTAStorage& storage) {
^
C:/Users/lesko/.platformio/lib/ArduinoOTA_ID6178/src/ArduinoOTA.h:91:8: note: candidate expects 4 arguments, 0 provided
Compiling .pio\build\esp32doit-devkit-v1\lib527\WiFi101_ID299\WiFi.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib527\WiFi101_ID299\WiFiClient.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib527\WiFi101_ID299\WiFiMDNSResponder.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib527\WiFi101_ID299\WiFiSSLClient.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib527\WiFi101_ID299\WiFiServer.cpp.o
*** [.pio\build\esp32doit-devkit-v1\src\main.cpp.o] Error 1
C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFiMDNSResponder.cpp:24:26: fatal error: avr/pgmspace.h: No such file or directory
compilation terminated.
*** [.pio\build\esp32doit-devkit-v1\lib527\WiFi101_ID299\WiFiMDNSResponder.cpp.o] Error 1
In file included from C:\Users\lesko.platformio\packages\framework-arduinoespressif32\tools\sdk\include\newlib/time.h:10:0,
from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFi.cpp:28:
C:\Users\lesko.platformio\packages\framework-arduinoespressif32\tools\sdk\include\newlib/sys/unistd.h:30:9: error: conflicting declaration of C function ‘int close(int)’
int _EXFUN(close, (int __fildes ));
^
In file included from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\utility/WiFiSocket.h:24:0,
from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFi.cpp:36:
C:\Users\lesko.platformio\lib\WiFi101_ID299\src/socket/include/socket.h:1839:15: note: previous declaration ‘sint8 close(SOCKET)’
NMI_API sint8 close(SOCKET sock);
^
In file included from C:\Users\lesko.platformio\packages\framework-arduinoespressif32\tools\sdk\include\newlib/stdio.h:29:0,
from C:\Users\lesko.platformio\packages\framework-arduinoespressif32\cores\esp32/Arduino.h:27,
from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\utility/WiFiSocket.h:28,
from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFiClient.cpp:20:
C:\Users\lesko.platformio\packages\framework-arduinoespressif32\tools\sdk\include\newlib/sys/unistd.h:30:9: error: conflicting declaration of C function ‘int close(int)’
int _EXFUN(close, (int __fildes ));
^
In file included from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\utility/WiFiSocket.h:24:0,
from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFiClient.cpp:20:
C:\Users\lesko.platformio\lib\WiFi101_ID299\src/socket/include/socket.h:1839:15: note: previous declaration ‘sint8 close(SOCKET)’
NMI_API sint8 close(SOCKET sock);
^
In file included from C:\Users\lesko.platformio\packages\framework-arduinoespressif32\tools\sdk\include\newlib/stdio.h:29:0,
from C:\Users\lesko.platformio\packages\framework-arduinoespressif32\cores\esp32/Arduino.h:27,
from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\utility/WiFiSocket.h:28,
from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFiServer.cpp:20:
C:\Users\lesko.platformio\packages\framework-arduinoespressif32\tools\sdk\include\newlib/sys/unistd.h:30:9: error: conflicting declaration of C function ‘int close(int)’
int _EXFUN(close, (int __fildes ));
^
In file included from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\utility/WiFiSocket.h:24:0,
from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFiServer.cpp:20:
C:\Users\lesko.platformio\lib\WiFi101_ID299\src/socket/include/socket.h:1839:15: note: previous declaration ‘sint8 close(SOCKET)’
NMI_API sint8 close(SOCKET sock);
^
C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFi.cpp: In member function ‘int WiFiClass::init()’:
C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFi.cpp:303:46: error: invalid conversion from ‘void ()(uint8_t, uint32_t) {aka void ()(unsigned char, unsigned int)}’ to ‘tpfAppResolveCb {aka void ()(unsigned
char
, long unsigned int)}’ [-fpermissive]
registerSocketCallback(socket_cb, resolve_cb);
^
In file included from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\utility/WiFiSocket.h:24:0,
from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFi.cpp:36:
C:\Users\lesko.platformio\lib\WiFi101_ID299\src/socket/include/socket.h:1047:14: note: initializing argument 2 of ‘void registerSocketCallback(tpfAppSocketCb, tpfAppResolveCb)’
NMI_API void registerSocketCallback(tpfAppSocketCb socket_cb, tpfAppResolveCb resolve_cb);
^
C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFi.cpp: At global scope:
C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFi.cpp:1133:10: error: prototype for ‘uint32_t WiFiClass::getTime()’ does not match any in class ‘WiFiClass’
uint32_t WiFiClass::getTime()
^
In file included from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFi.cpp:38:0:
C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFi101.h:157:16: error: candidate is: long unsigned int WiFiClass::getTime()
unsigned long getTime();
^
*** [.pio\build\esp32doit-devkit-v1\lib527\WiFi101_ID299\WiFiClient.cpp.o] Error 1
*** [.pio\build\esp32doit-devkit-v1\lib527\WiFi101_ID299\WiFi.cpp.o] Error 1
In file included from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFiClient.h:28:0,
from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFiSSLClient.h:23,
from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFiSSLClient.cpp:20:
C:\Users\lesko.platformio\lib\WiFi101_ID299\src\socket/include/socket.h:1839:32: error: conflicting declaration of C function ‘sint8 close(SOCKET)’
NMI_API sint8 close(SOCKET sock);
^
In file included from C:\Users\lesko.platformio\packages\framework-arduinoespressif32\tools\sdk\include\newlib/stdio.h:29:0,
from C:\Users\lesko.platformio\packages\framework-arduinoespressif32\cores\esp32/Arduino.h:27,
from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFiClient.h:23,
from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFiSSLClient.h:23,
from C:\Users\lesko.platformio\lib\WiFi101_ID299\src\WiFiSSLClient.cpp:20:
C:\Users\lesko.platformio\packages\framework-arduinoespressif32\tools\sdk\include\newlib/sys/unistd.h:30:9: note: previous declaration ‘int close(int)’
int _EXFUN(close, (int __fildes ));
^
*** [.pio\build\esp32doit-devkit-v1\lib527\WiFi101_ID299\WiFiServer.cpp.o] Error 1
*** [.pio\build\esp32doit-devkit-v1\lib527\WiFi101_ID299\WiFiSSLClient.cpp.o] Error 1

This looks not good, since WiFi101 shouldn’t be pulled as an external library into the ESP32 arduino core, it brings its own. This screws up compilation.

Can you add lib_ignore = WiFi101 to the platformio.ini?

Also then we’d need to see your full platformio.ini and code you’re compiling.

1 Like

In addition to what @maxgerhardt said, it looks like the WiFi101 library is installed globally, since it’s in the main .platformio\lib folder as well. Try not to install libraries this way, as if you have a globally installed library which is not compatible with all the boards / architectures you are working it, you’ll get errors like this and have to explicity ignore those libraries. If you need it for a given project, it is best to define it via the lib_deps line for a given project, and it won’t interfere with any other projects.

Okay, thank you very much. Firstly I tried unistalling all the libraries and everything but all I got was missing references, functions and stuff. So in the end I decided to completely remove Platformio, and whole platformio folder with all the libraries for other platforms and everything. I then installed platformio again and installed wifi101 library to my esp32 project. It works now so thank you very much for all the help provided! Now I just have to import other projects I did on Due and esp8266 and hopefully it will work :slight_smile:
Thanks you all again! Hopefully my answer will help others.

1 Like