PlatformIO Community

Wifi Compiling Problem

Hello.
When i try to compile my programm that i imported from Arduino i get this error:

object of abstract class type “WiFiUDP” is not allowed: – pure virtual function “UDP::remoteIP” has no overrider – pure virtual function “UDP::remotePort” has no overrider
and many more e.g. this:
error: invalid abstract return type for member function ‘WiFiClient WiFiServer::available(uint8_t*)’
Is there a Problem with the WiFi class in PlatfromIO because it is working in Arduino IDE.
This is the beginning of the programm:

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#include <ESP8266WiFi.h>
#include <WiFi.h>
#include <Arduino.h>
#include <TimeLib.h>
#include  <WiFiUdp.h>
#include <WiFiUdp.h>
WiFiClient client;
WiFiUDP udp;

The Problem is WifiUDP udp; VSC marks this red.
The whole errore looks like this

> Executing task in folder 190414-164233-d1_mini: C:\Users\User\.platformio\penv\Scripts\platformio.exe run --target upload <

_Processing d1_mini (platform: espressif8266; board: d1_mini; framework: arduino)_
_-----------------------------------------------------------------------------------------------------------------------------------------------_
_Verbose mode can be enabled via `-v, --verbose` option_
_CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini.html_
_PLATFORM: Espressif 8266 > WeMos D1 R2 and mini_
_HARDWARE: ESP8266 80MHz 80KB RAM (4MB Flash)_
_Converting bildschrim.ino_
_Library Dependency Finder -> http://bit.ly/configure-pio-ldf_
_LDF MODES: FINDER(chain) COMPATIBILITY(soft)_
_Collected 34 compatible libraries_
_Scanning dependencies..._
_Dependency Graph_
_|-- <Adafruit MQTT Library> 0.20.4_
_|-- <ESP8266WebServer> 1.0_
_|   |-- <WiFi> 1.2.7_
_|   |   |-- <SPI> 1.0_
_|   |-- <ESP8266WiFi> 1.0_
_|-- <WiFi> 1.2.7_
_|   |-- <SPI> 1.0_
_|-- <Adafruit GFX Library> 1.4.9_
_|   |-- <SPI> 1.0_
_|-- <Time> 1.5_
_|-- <ESP8266WiFi> 1.0_
_|-- <SPI> 1.0_
_|-- <Adafruit ST7735 and ST7789 Library> 1.2.8_
_|   |-- <SPI> 1.0_
_|   |-- <Adafruit GFX Library> 1.4.9_
_|   |   |-- <SPI> 1.0_
_Compiling .pioenvs\d1_mini\src\bildschrim.ino.cpp.o_
_Compiling .pioenvs\d1_mini\lib204\WiFi_ID870\WiFi.cpp.o_
_Compiling .pioenvs\d1_mini\lib204\WiFi_ID870\WiFiClient.cpp.o_
_Compiling .pioenvs\d1_mini\lib204\WiFi_ID870\WiFiServer.cpp.o_
_Compiling .pioenvs\d1_mini\lib204\WiFi_ID870\WiFiUdp.cpp.o_
_In file included from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.h:32:0,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.cpp:21:_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.h:37:14: error: invalid abstract return type for member function 'WiFiClient WiFiServer::available(uint8_t*)'_
_WiFiClient available(uint8_t* status = NULL);_
_^_
_In file included from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.h:31:0,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.cpp:21:_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiClient.h:27:7: note:   because the following virtual functions are pure within 'WiFiClient':_
_class WiFiClient : public Client {_
_^_
_In file included from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiClient.h:24:0,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.h:31,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.cpp:21:_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Client.h:29:21: note:         virtual int Client::connect(const IPAddress&, uint16_t)_
_virtual int connect(CONST IPAddress& ip, uint16_t port) =0;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Client.h:37:22: note:         virtual bool Client::flush(unsigned int)_
_virtual bool flush(unsigned int maxWaitMs = 0) = 0;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Client.h:38:22: note:         virtual bool Client::stop(unsigned int)_
_virtual bool stop(unsigned int maxWaitMs = 0) = 0;_
_^_
_In file included from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.h:32:0,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiClient.cpp:27:_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.h:37:14: error: invalid abstract return type for member function 'WiFiClient WiFiServer::available(uint8_t*)'_
_WiFiClient available(uint8_t* status = NULL);_
_^_
_In file included from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.h:31:0,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiClient.cpp:27:_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiClient.h:27:7: note:   because the following virtual functions are pure within 'WiFiClient':_
_class WiFiClient : public Client {_
_^_
_In file included from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiClient.h:24:0,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.h:31,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiClient.cpp:27:_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Client.h:29:21: note:         virtual int Client::connect(const IPAddress&, uint16_t)_
_virtual int connect(CONST IPAddress& ip, uint16_t port) =0;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Client.h:37:22: note:         virtual bool Client::flush(unsigned int)_
_virtual bool flush(unsigned int maxWaitMs = 0) = 0;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Client.h:38:22: note:         virtual bool Client::stop(unsigned int)_
_virtual bool stop(unsigned int maxWaitMs = 0) = 0;_
_^_
_In file included from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.h:32:0,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.cpp:27:_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.h:37:14: error: invalid abstract return type for member function 'WiFiClient WiFiServer::available(uint8_t*)'_
_WiFiClient available(uint8_t* status = NULL);_
_^_
_In file included from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.h:31:0,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.cpp:27:_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiClient.h:27:7: note:   because the following virtual functions are pure within 'WiFiClient':_
_class WiFiClient : public Client {_
_^_
_In file included from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiClient.h:24:0,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.h:31,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.cpp:27:_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Client.h:29:21: note:         virtual int Client::connect(const IPAddress&, uint16_t)_
_virtual int connect(CONST IPAddress& ip, uint16_t port) =0;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Client.h:37:22: note:         virtual bool Client::flush(unsigned int)_
_virtual bool flush(unsigned int maxWaitMs = 0) = 0;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Client.h:38:22: note:         virtual bool Client::stop(unsigned int)_
_virtual bool stop(unsigned int maxWaitMs = 0) = 0;_
_^_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.cpp: In member function 'WiFiClient WiFiServer::available(byte*)':_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.cpp:47:12: error: invalid abstract return type for member function 'WiFiClient WiFiServer::available(byte*)'_
_WiFiClient WiFiServer::available(byte* status)_
_^_
_In file included from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.h:31:0,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.cpp:27:_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiClient.h:27:7: note:   since type 'WiFiClient' has pure virtual functions_
_class WiFiClient : public Client {_
_^_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.cpp:56:21: error: cannot declare variable 'client' to be of abstract type 'WiFiClient'_
_WiFiClient client(sock);_
_^_
_In file included from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.h:31:0,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.cpp:27:_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiClient.h:27:7: note:   since type 'WiFiClient' has pure virtual functions_
_class WiFiClient : public Client {_
_^_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.cpp:72:24: error: cannot allocate an object of abstract type 'WiFiClient'_
_return client;  //TODO_
_^_
_In file included from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.h:31:0,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.cpp:27:_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiClient.h:27:7: note:   since type 'WiFiClient' has pure virtual functions_
_class WiFiClient : public Client {_
_^_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.cpp:77:26: error: cannot allocate an object of abstract type 'WiFiClient'_
_return WiFiClient(255);_
_^_
_In file included from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.h:31:0,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.cpp:27:_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiClient.h:27:7: note:   since type 'WiFiClient' has pure virtual functions_
_class WiFiClient : public Client {_
_^_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.cpp: In member function 'virtual size_t WiFiServer::write(const uint8_t*, size_t)':_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.cpp:98:21: error: cannot declare variable 'client' to be of abstract type 'WiFiClient'_
_WiFiClient client(sock);_
_^_
_In file included from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.h:31:0,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.cpp:27:_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiClient.h:27:7: note:   since type 'WiFiClient' has pure virtual functions_
_class WiFiClient : public Client {_
_^_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.cpp: In member function 'WiFiClient WiFiServer::available(byte*)':_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.cpp:78:1: warning: control reaches end of non-void function [-Wreturn-type]_
_}_
_^_
_C:/Users/User/Documents/PlatformIO/Projects/190414-164233-d1_mini/src/bildschrim.ino:17:1: error: 'f' does not name a type_
_char *ssid      = "WLANSSID";               // Set you WiFi SSID_
_^_
_In file included from C:/Users/User/Documents/PlatformIO/Projects/190414-164233-d1_mini/src/bildschrim.ino:21:0:_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/WiFiUdp.h:32:27: error: expected class-name before ',' token_
_class WiFiUDP : public UDP, public SList<WiFiUDP> {_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/WiFiUdp.h:78:16: error: type 'Print' is not a base type for type 'WiFiUDP'_
_using Print::write;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/WiFiUdp.h:46:11: error: 'uint8_t WiFiUDP::begin(uint16_t)' marked override, but does not override_
_uint8_t begin(uint16_t port) override;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/WiFiUdp.h:48:8: error: 'void WiFiUDP::stop()' marked override, but does not override_
_void stop() override;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/WiFiUdp.h:56:7: error: 'int WiFiUDP::beginPacket(IPAddress, uint16_t)' marked override, but does not override_
_int beginPacket(IPAddress ip, uint16_t port) override;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/WiFiUdp.h:59:7: error: 'int WiFiUDP::beginPacket(const char*, uint16_t)' marked override, but does not override_
_int beginPacket(const char *host, uint16_t port) override;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/WiFiUdp.h:72:7: error: 'int WiFiUDP::endPacket()'_
_marked override, but does not override_
_int endPacket() override;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/WiFiUdp.h:74:10: error: 'size_t WiFiUDP::write(uint8_t)' marked override, but does not override_
_size_t write(uint8_t) override;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/WiFiUdp.h:76:10: error: 'size_t WiFiUDP::write(const uint8_t*, size_t)' marked override, but does not override_
_size_t write(const uint8_t *buffer, size_t size) override;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/WiFiUdp.h:82:7: error: 'int WiFiUDP::parsePacket()' marked override, but does not override_
_int parsePacket() override;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/WiFiUdp.h:84:7: error: 'int WiFiUDP::available()'_
_marked override, but does not override_
_int available() override;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/WiFiUdp.h:86:7: error: 'int WiFiUDP::read()' marked override, but does not override_
_int read() override;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/WiFiUdp.h:89:7: error: 'int WiFiUDP::read(unsigned char*, size_t)' marked override, but does not override_
_int read(unsigned char* buffer, size_t len) override;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/WiFiUdp.h:92:7: error: 'int WiFiUDP::read(char*, size_t)' marked override, but does not override_
_int read(char* buffer, size_t len) override { return read((unsigned char*)buffer, len); };_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/WiFiUdp.h:94:7: error: 'int WiFiUDP::peek()' marked override, but does not override_
_int peek() override;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/WiFiUdp.h:95:8: error: 'void WiFiUDP::flush()' marked override, but does not override_
_void flush() override; // Finish reading the current packet_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/WiFiUdp.h:98:13: error: 'IPAddress WiFiUDP::remoteIP() const' marked override, but does not override_
_IPAddress remoteIP() const override;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/WiFiUdp.h:100:12: error: 'uint16_t WiFiUDP::remotePort() const' marked override, but does not override_
_uint16_t remotePort() const override;_
_^_
_In file included from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.h:32:0,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiUdp.cpp:28:_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiServer.h:37:14: error: invalid abstract return type for member function 'WiFiClient WiFiServer::available(uint8_t*)'_
_WiFiClient available(uint8_t* status = NULL);_
_^_
_In file included from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.h:31:0,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiUdp.cpp:28:_
_C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiClient.h:27:7: note:   because the following virtual functions are pure within 'WiFiClient':_
_class WiFiClient : public Client {_
_^_
_In file included from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiClient.h:24:0,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFi.h:31,_
_from C:\Users\User\.platformio\lib\WiFi_ID870\src\WiFiUdp.cpp:28:_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Client.h:29:21: note:         virtual int Client::connect(const IPAddress&, uint16_t)_
_virtual int connect(CONST IPAddress& ip, uint16_t port) =0;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Client.h:37:22: note:         virtual bool Client::flush(unsigned int)_
_virtual bool flush(unsigned int maxWaitMs = 0) = 0;_
_^_
_C:\Users\User\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Client.h:38:22: note:         virtual bool Client::stop(unsigned int)_
_virtual bool stop(unsigned int maxWaitMs = 0) = 0;_
_^_
_C:/Users/User/Documents/PlatformIO/Projects/190414-164233-d1_mini/src/bildschrim.ino:33:14: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]_
_Adafruit_MQTT_Subscribe Feuchte= Adafruit_MQTT_Subscribe(&mqtt, "/weatherStation/humidity");_
_^_
_C:/Users/User/Documents/PlatformIO/Projects/190414-164233-d1_mini/src/bildschrim.ino:35:18: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]_
_void MQTT_connect();_


_^_
_Compiling .pioenvs\d1_mini\FrameworkArduino\core_esp8266_wiring_analog.c.o_
_Compiling .pioenvs\d1_mini\FrameworkArduino\core_esp8266_wiring_digital.c.o_
_Compiling .pioenvs\d1_mini\FrameworkArduino\core_esp8266_wiring_pulse.c.o_
_Compiling .pioenvs\d1_mini\FrameworkArduino\core_esp8266_wiring_pwm.c.o_
_Compiling .pioenvs\d1_mini\FrameworkArduino\core_esp8266_wiring_shift.c.o_
_Compiling .pioenvs\d1_mini\FrameworkArduino\debug.cpp.o_
_Compiling .pioenvs\d1_mini\FrameworkArduino\gdb_hooks.c.o_
_Compiling .pioenvs\d1_mini\FrameworkArduino\heap.c.o_
_Compiling .pioenvs\d1_mini\FrameworkArduino\libb64\cdecode.c.o_
_Compiling .pioenvs\d1_mini\FrameworkArduino\libb64\cencode.c.o_
_*** [.pioenvs\d1_mini\lib204\WiFi_ID870\WiFi.cpp.o] Error 1_
_*C** [.pioenvs\d1_mini\lib204\WiFi_ID870\WiFiClient.cpp.o] Error 1ompiling .pioenvs\d1_mini\FrameworkArduino\libc_replacements.c.o_

_*** [.pioenvs\d1_mini\lib204\WiFi_ID870\WiFiServer.cpp.o] Error 1_
_*** [.pioenvs\d1_mini\lib204\WiFi_ID870\WiFiUdp.cpp.o] Error 1_
_*** [.pioenvs\d1_mini\src\bildschrim.ino.cpp.o] Error 1_
_========================================================== [ERROR] Took 2.80 seconds ==========================================================_
_The terminal process terminated with exit code: 1_
1 Like

May just be me, but I’m having the exact same issue…

Me +1

Worst thing is it works with the Arudino IDE. So i will just have to do it the old way. Maybe copy the code into Arduino IDE to enjoy the benefits of VSC and then upload it with Aruduino IDE to Wemos.

Irreproducible for me.

Make sure you’re on the latest version or execute the Rebuild IntelliSense Index target on the left.

I solved the issue - you cant only use the <WiFi.h> reference, you have to use the platform-specific wifi header, ie the Esp8266Wifi.h file instead. The warnings refer to abstract code being used, ie missing actual function definitions, which apparently are contained per platform header.

solution: use the ESP8266WiFi.h file instead (or corresponding for ESP32 and others)

1 Like

Hi, I’m using an esp32 and solved this issue including dependencies in the platformio.ini file like these:
lib_deps =
https://github.com/knolleary/pubsubclient.git
https://github.com/espressif/arduino-esp32.git

and I haven’t installed WiFi library.