Import example from Adafruit gives compile error

I have imported the “Adafruit IO Publish Example” that works well in the Arduino IDE. PlatformIO Registry
After importing i solved some initial compile error by adding some more lib_deps

lib_deps =
  Wire
  Ethernet
  Adafruit MQTT Library
  Adafruit IO Arduino

No I get the following error:

#define ntohl(x) lwip_ntohl(x)
 ^
.pio/libdeps/nodemcuv2/Ethernet_ID872/src/Ethernet.cpp: In static member function 'static void EthernetClass::begin(uint8_t*, IPAddress, IPAddress, IPAddress, IPAddress)':
.pio/libdeps/nodemcuv2/Ethernet_ID872/src/Ethernet.cpp:87:24: error: 'class IPAddress' has no member named '_address'
  W5100.setIPAddress(ip._address.bytes);
                    ^
.pio/libdeps/nodemcuv2/Ethernet_ID872/src/Ethernet.cpp:88:29: error: 'class IPAddress' has no member named '_address'
  W5100.setGatewayIp(gateway._address.bytes);
                         ^
.pio/libdeps/nodemcuv2/Ethernet_ID872/src/Ethernet.cpp:89:29: error: 'class IPAddress' has no member named '_address'
  W5100.setSubnetMask(subnet._address.bytes);
                         ^
*** [.pio/build/nodemcuv2/lib0ff/Ethernet_ID872/Ethernet.cpp.o] Error 1

I can reproduce this with platformIO and also confirm that with the latest 2.7.1 esp8266 arduino BSP and latest Adafruit IO Library, Adafruit MQTT Library and Arduino HTTP library (per the Adafruit install guide) that the example should still compiles without error for a nodemcu_v1 target.

Digging a bit deeper into the PlatformIO side of things, since for an ESP8266 I don’t think a external ethernet library should be used, I just deleted the ethernet_id872 folder from the .pio/lib_deps folder, and got a different error message about the esp32servo library, so deleted that also since it’s the wrong architecture. And then the example compiled successfully. Oh, I added SPI and Wire to the main.cpp, instead of the platformio.ini, but whatever works.

But that really isn’t a fix… and I’m don’t know how to remedy this (outside of an extra_script that deletes those libraries if present, but that still feels hacky). Because they are library dependencies of ‘Adafruit IO Library’, it seems like using lib_ignore doesn’t work to block them from auto-installing when that library isn’t installed. Setting lib_compat_mode to strict (so that compatability with the platform is checked) didn’t block it. And setting the LDF Finder mode to deep+ doesn’t seem to remedy the issue either (as I hoped there would be macros that would stop those lines/libraries being used).

Thanks for the swift reply.
I will test this…
Should I report this as an issue in the PlatformIO Core Github repo?
Regards, Jesper

I think it’s more an issue of how Adafruit have configured the dependencies, or haven’t. They use the Arduino IDE library.properties, which AFAIK doesn’t allow them to specify that libraries such as esp32servo or Ethernet are not to be downloaded for the ESP8266, etc. So PlatformIO is just doing what it’s told - pull those dependencies… but once it’s downloaded, I’m not sure why the architectures=esp32 in esp32servo didn’t prevent that library from been included in the compile. Ethernet is marked as esp8266 compatible (actually, compatible with all architectures, which is plain wrong), but it obviously isn’t working.

I would actually lodge an issue against GitHub - adafruit/Adafruit_IO_Arduino: Arduino library to access Adafruit IO from WiFi, cellular, and ethernet modules., and ask if/when are they going to use a library.json manifest so their library will work correctly on PlatformIO.