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

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

Open
aspymid opened this issue Dec 17, 2024 · 2 comments · May be fixed by #180
Open

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

aspymid opened this issue Dec 17, 2024 · 2 comments · May be fixed by #180
Labels
status: in progress Work is in progress on this topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@aspymid
Copy link

aspymid commented Dec 17, 2024

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;
      |               ^~~~~~~
@per1234 per1234 added the type: imperfection Perceived defect in any part of project label Dec 17, 2024
@per1234 per1234 changed the title OTA will not compile with the lastest arduino system updates Library compilation fails with "esp32" boards platform version 3.1.0 Dec 17, 2024
@per1234 per1234 transferred this issue from arduino-libraries/Arduino_ESP32_OTA Dec 17, 2024
@per1234 per1234 linked a pull request Dec 17, 2024 that will close this issue
@MathewHDYT
Copy link

MathewHDYT commented Dec 22, 2024

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
Copy link

per1234 commented Dec 24, 2024

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

@per1234 per1234 added topic: code Related to content of the project itself status: in progress Work is in progress on this labels Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: in progress Work is in progress on this topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants