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;
      |               ^~~~~~~

Activity

changed the title [-]OTA will not compile with the lastest arduino system updates [/-] [+]Library compilation fails with "esp32" boards platform version 3.1.0[/+] on Dec 17, 2024
MathewHDYT

MathewHDYT commented on Dec 22, 2024

@MathewHDYT

This issue causes all libraries that use the ArduinoHttpClient to not compile anymore if the aforementioned missing method int connect(const char *host, uint16_t port, int32_t timeout) is not added by hand. Would it be possible to simply add it with a #define check for now.

So something like this using the Arduino Version flags:

#ifdef ESP_ARDUINO_VERSION_MAJOR
#if ESP_ARDUINO_VERSION_MAJOR > 3 && ESP_ARDUINO_VERSION_MINOR > 1
int connect(const char *host, uint16_t port, int32_t timeout) override {
    ...
}
#endif // ESP_ARDUINO_VERSION_MAJOR > 3 && ESP_ARDUINO_VERSION_MINOR > 1
#endif // ESP_ARDUINO_VERSION_MAJOR

Would be nice if the linked Pull Request could be merged as soon as possible.

per1234

per1234 commented on Dec 24, 2024

@per1234

A proposal has now been submitted to revert the breaking change in the esp32 platform's Client API: espressif/arduino-esp32#10776

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

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

      Participants

      @per1234@MathewHDYT@aspymid

      Issue actions

        Library compilation fails with "esp32" boards platform version 3.1.0 · Issue #182 · arduino-libraries/ArduinoHttpClient