Skip to content

Compilation error when using PlatformIO and Ethernet.h #277

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

Open
MicSG-dev opened this issue Dec 19, 2024 · 4 comments
Open

Compilation error when using PlatformIO and Ethernet.h #277

MicSG-dev opened this issue Dec 19, 2024 · 4 comments
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

@MicSG-dev
Copy link

When using PlatformIO with the following platformio.ini file:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
    arduino-libraries/Ethernet@^2.0.2

And running the WebServer example, several compilation errors occur:

src/main.cpp: In function 'void loop()':
src/main.cpp:75:43: error: cannot allocate an object of abstract type 'EthernetClient'
   75 |   EthernetClient client = server.available();
      |                           ~~~~~~~~~~~~~~~~^~
In file included from src/main.cpp:22:
.pio/libdeps/esp32dev/Ethernet/src/Ethernet.h:214:7: note:   because the following virtual functions are pure within 'EthernetClient':
  214 | class EthernetClient : public Client {
      |       ^~~~~~~~~~~~~~
In file included from C:/Users/MichelGalvao/.platformio/packages/framework-arduinoespressif32@src-e5a7fd5d9117bd8a322277fde59ac3d3/cores/esp32/Arduino.h:197,
                 from src/main.cpp:20:
C:/Users/MichelGalvao/.platformio/packages/framework-arduinoespressif32@src-e5a7fd5d9117bd8a322277fde59ac3d3/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/MichelGalvao/.platformio/packages/framework-arduinoespressif32@src-e5a7fd5d9117bd8a322277fde59ac3d3/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;
      |               ^~~~~~~
src/main.cpp:75:18: error: cannot declare variable 'client' to be of abstract type 'EthernetClient'
   75 |   EthernetClient client = server.available();
      |                  ^~~~~~
Compiling .pio\build\esp32dev\FrameworkArduino\FunctionalInterrupt.cpp.o
*** [.pio\build\esp32dev\src\main.cpp.o] Error 1
.pio/libdeps/esp32dev/Ethernet/src/EthernetServer.cpp:40:16: error: invalid abstract return type for member function 'EthernetClient EthernetServer::available()'
   40 | EthernetClient EthernetServer::available()
      |                ^~~~~~~~~~~~~~
In file included from .pio/libdeps/esp32dev/Ethernet/src/EthernetServer.cpp:22:
.pio/libdeps/esp32dev/Ethernet/src/Ethernet.h:214:7: note:   because the following virtual functions are pure within 'EthernetClient':
  214 | class EthernetClient : public Client {
      |       ^~~~~~~~~~~~~~
In file included from C:/Users/MichelGalvao/.platformio/packages/framework-arduinoespressif32@src-e5a7fd5d9117bd8a322277fde59ac3d3/cores/esp32/Arduino.h:197,
                 from .pio/libdeps/esp32dev/Ethernet/src/EthernetServer.cpp:21:
C:/Users/MichelGalvao/.platformio/packages/framework-arduinoespressif32@src-e5a7fd5d9117bd8a322277fde59ac3d3/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/MichelGalvao/.platformio/packages/framework-arduinoespressif32@src-e5a7fd5d9117bd8a322277fde59ac3d3/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;
      |               ^~~~~~~
.pio/libdeps/esp32dev/Ethernet/src/EthernetServer.cpp: In member function 'EthernetClient EthernetServer::available()':
.pio/libdeps/esp32dev/Ethernet/src/EthernetServer.cpp:47:54: error: invalid cast to abstract class type 'EthernetClient'
   47 |         if (!chip) return EthernetClient(MAX_SOCK_NUM);
      |                                                      ^
.pio/libdeps/esp32dev/Ethernet/src/EthernetServer.cpp:72:40: error: invalid cast to abstract class type 'EthernetClient'
   72 |         return EthernetClient(sockindex);
      |                                        ^
.pio/libdeps/esp32dev/Ethernet/src/EthernetServer.cpp: At global scope:
.pio/libdeps/esp32dev/Ethernet/src/EthernetServer.cpp:75:16: error: invalid abstract return type for member function 'EthernetClient EthernetServer::accept()'
   75 | EthernetClient EthernetServer::accept()
      |                ^~~~~~~~~~~~~~
.pio/libdeps/esp32dev/Ethernet/src/EthernetServer.cpp: In member function 'EthernetClient EthernetServer::accept()':
.pio/libdeps/esp32dev/Ethernet/src/EthernetServer.cpp:82:54: error: invalid cast to abstract class type 'EthernetClient'
   82 |         if (!chip) return EthernetClient(MAX_SOCK_NUM);
      |                                                      ^
.pio/libdeps/esp32dev/Ethernet/src/EthernetServer.cpp:104:40: error: invalid cast to abstract class type 'EthernetClient'
  104 |         return EthernetClient(sockindex);
      |                                        ^
.pio/libdeps/esp32dev/Ethernet/src/EthernetServer.cpp: In member function 'virtual size_t EthernetServer::write(const uint8_t*, size_t)':
.pio/libdeps/esp32dev/Ethernet/src/EthernetServer.cpp:170:18: error: cannot allocate an object of abstract type 'EthernetClient'
  170 |         available();
      |         ~~~~~~~~~^~
*** [.pio\build\esp32dev\libe72\Ethernet\EthernetServer.cpp.o] Error 1
@per1234
Copy link
Contributor

per1234 commented Dec 19, 2024

It is caused by the ESP32 platform deviating from the standardized Arduino Client class API:

espressif/arduino-esp32#2755

They brought the platform back into compliance some time ago: espressif/arduino-esp32#3191

But then there was a recent regression: espressif/arduino-esp32#10202

I am not knowledgeable in the subject matter of PlatformIO, but my understanding is that the PlatformIO platform is significantly outdated: platformio/platform-espressif32#1225, so I guess you are probably still suffering from the original incarnation of the bug rather than the current one.

@MicSG-dev
Copy link
Author

MicSG-dev commented Dec 19, 2024

Got it. Thanks for the links. I was able to fix the errors temporarily by applying the changes to the Client.h file (removing line 29 and line 31), which is located in C:\Users\<USER>\.platformio\packages\<PACKAGE>\cores\esp32\Client.h, whose changes were made according to pull request 3191.

@per1234
Copy link
Contributor

per1234 commented Dec 24, 2024

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

@per1234 per1234 added 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 labels Dec 24, 2024
@MicSG-dev
Copy link
Author

Thank you very much for the information!! I will eagerly await the result.

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

No branches or pull requests

2 participants