Skip to content

Library compilation fails with "esp32" boards platform version 3.1.0 #182

Open
@aspymid

Description

@aspymid

Describe the problem

Version 3.1.0 of the "esp32" boards platform was recently released:

https://github.com/espressif/arduino-esp32/releases/tag/3.1.0

Although the library compiled without errors for boards from the previous version 3.0.7 of the platform, it fails to compile after updating to version 3.1.0 of the platform.

To reproduce

  1. Install the latest version of the "esp32" boards platform:
    https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html#installing-using-arduino-ide
  2. Create a sketch with the following content:
    #include <ArduinoHttpClient.h>
    #include <WiFi.h>
    WiFiClient wifi;
    HttpClient client = HttpClient(wifi, "192.168.0.3", 42);
    void setup() {}
    void loop() {}
  3. Select Tools > Board > esp32 > ESP32 Dev Module from the Arduino IDE menus.
    This board was chosen arbitrarily for the sake of the demo. The fault also occurs with other boards of the platform.
  4. Select Sketch > Verify/Compile from the Arduino IDE menus.

🐛 Compilation fails:

C:\Users\per\AppData\Local\Temp\.arduinoIDE-unsaved20241116-15248-zm3y3w.s57w\sketch_dec16a\sketch_dec16a.ino:4:55: error: invalid cast to abstract class type 'HttpClient'
    4 | HttpClient client = HttpClient(wifi, "192.168.0.3", 42);
      |                                                       ^
In file included from c:\Users\per\Documents\Arduino\libraries\ArduinoHttpClient\src/ArduinoHttpClient.h:8,
                 from C:\Users\per\AppData\Local\Temp\.arduinoIDE-unsaved20241116-15248-zm3y3w.s57w\sketch_dec16a\sketch_dec16a.ino:1:
c:\Users\per\Documents\Arduino\libraries\ArduinoHttpClient\src/HttpClient.h:41:7: note:   because the following virtual functions are pure within 'HttpClient':
   41 | class HttpClient : public Client
      |       ^~~~~~~~~~
In file included from C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0\cores\esp32/Arduino.h:197,
                 from C:\Users\per\AppData\Local\arduino\sketches\6312FDE06C3278D1531C362779D83BA5\sketch\sketch_dec16a.ino.cpp:1:
C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0\cores\esp32/Client.h:29:15: note:     'virtual int Client::connect(IPAddress, uint16_t, int32_t)'
   29 |   virtual int connect(IPAddress ip, uint16_t port, int32_t timeout) = 0;
      |               ^~~~~~~
C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0\cores\esp32/Client.h:31:15: note:     'virtual int Client::connect(const char*, uint16_t, int32_t)'
   31 |   virtual int connect(const char *host, uint16_t port, int32_t timeout) = 0;
      |               ^~~~~~~
C:\Users\per\AppData\Local\Temp\.arduinoIDE-unsaved20241116-15248-zm3y3w.s57w\sketch_dec16a\sketch_dec16a.ino:4:12: error: cannot declare variable 'client' to be of abstract type 'HttpClient'
    4 | HttpClient client = HttpClient(wifi, "192.168.0.3", 42);
      |            ^~~~~~

Expected behavior

Library compiles with the latest version of the supported boards platforms.

ArduinoHttpClient version

Original report

0.3.1

Last verified with

7b509784ce4dd988b5213b14babec2f8338f6619

Additional context

The regression was introduced by espressif/arduino-esp32@e1673e4


Of course this also breaks the use of libraries which introduce a transitory dependency on the "ArduinoHttpClient" library. For example, the "Arduino_ESP32_OTA" library:

#include <Arduino_ESP32_OTA.h>
void setup() {}
void loop() {}
c:\Users\per\Documents\Arduino\libraries\Arduino_ESP32_OTA\src\Arduino_ESP32_OTA.cpp: In member function 'int Arduino_ESP32_OTA::startDownload(const char*)':
c:\Users\per\Documents\Arduino\libraries\Arduino_ESP32_OTA\src\Arduino_ESP32_OTA.cpp:144:99: error: invalid new-expression of abstract class type 'HttpClient'
  144 |   _http_client = new HttpClient(*_client, _context->parsed_url.host(), _context->parsed_url.port());
      |                                                                                                   ^
In file included from c:\Users\per\Documents\Arduino\libraries\ArduinoHttpClient\src/ArduinoHttpClient.h:8,
                 from c:\Users\per\Documents\Arduino\libraries\Arduino_ESP32_OTA\src\Arduino_ESP32_OTA.h:30,
                 from c:\Users\per\Documents\Arduino\libraries\Arduino_ESP32_OTA\src\Arduino_ESP32_OTA.cpp:23:
c:\Users\per\Documents\Arduino\libraries\ArduinoHttpClient\src/HttpClient.h:41:7: note:   because the following virtual functions are pure within 'HttpClient':
   41 | class HttpClient : public Client
      |       ^~~~~~~~~~
In file included from C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0\cores\esp32/Arduino.h:197,
                 from C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0\libraries\Update\src/Update.h:10,
                 from c:\Users\per\Documents\Arduino\libraries\Arduino_ESP32_OTA\src\Arduino_ESP32_OTA.cpp:22:
C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0\cores\esp32/Client.h:29:15: note:     'virtual int Client::connect(IPAddress, uint16_t, int32_t)'
   29 |   virtual int connect(IPAddress ip, uint16_t port, int32_t timeout) = 0;
      |               ^~~~~~~
C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.0\cores\esp32/Client.h:31:15: note:     'virtual int Client::connect(const char*, uint16_t, int32_t)'
   31 |   virtual int connect(const char *host, uint16_t port, int32_t timeout) = 0;
      |               ^~~~~~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: in progressWork is in progress on thistopic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions