Platform Native - Missing dependencies

PlatformIO is failling to compile for platform native, but works fine for espressif.

I noticed LDF fails to list some of the dependencies when running for platform native:

  • For espressif
    Collected 33 compatible libraries
    Looking for dependencies...
    Library Dependency Graph
    |-- <ProtoBuf>
    |   |-- <Nanopb> v0.3.9-dev
    |-- <ArduinoJson> v5.8.4
    |-- <Bounce2> v2.1
    |-- <Time> v1.5
    |-- <RTC> v2.0.0
    |-- <ESPAsyncTCP> v1.0.1
    |   |-- <ESP8266WiFi> v1.0
    |-- <Nanopb> v0.3.9-dev
    |-- <EEPROM> v1.0
    |-- <Homie> v2.0.0
    |   |-- <ArduinoJson> v5.8.4
    |   |-- <AsyncMqttClient> v0.5.0
    |   |   |-- <ESPAsyncTCP> v1.0.1
    |   |   |   |-- <ESP8266WiFi> v1.0
    |   |-- <Bounce2> v2.1
    |   |-- <ESP8266HTTPClient> v1.1
    |   |   |-- <ESP8266WiFi> v1.0
    |   |-- <ESP8266WebServer> v1.0
    |   |   |-- <ESP8266WiFi> v1.0
    |   |-- <ESP8266mDNS>
    |   |   |-- <ESP8266WiFi> v1.0
    |   |-- <ESP8266WiFi> v1.0
    |   |-- <Ticker> v1.0
    |   |-- <DNSServer> v1.1.0
    |   |   |-- <ESP8266WiFi> v1.0
    |   |-- <EEPROM> v1.0
    |-- <Crc16>
    |-- <AsyncMqttClient> v0.5.0
    |   |-- <ESPAsyncTCP> v1.0.1
    |   |   |-- <ESP8266WiFi> v1.0
    |-- <Wire> v1.0
  • For native
    Collected 13 compatible libraries
    Looking for dependencies...
    Library Dependency Graph
    |-- <ProtoBuf>
    |   |-- <Nanopb> v0.3.9-dev
    |-- <ArduinoJson> v5.8.4
    |-- <Bounce2> v2.1
    |-- <Time> v1.5
    |-- <RTC> v2.0.0
    |-- <ESPAsyncTCP> v1.0.1
    |-- <Nanopb> v0.3.9-dev
    |-- <Homie> v2.0.0
    |   |-- <ArduinoJson> v5.8.4
    |   |-- <AsyncMqttClient> v0.5.0
    |   |   |-- <ESPAsyncTCP> v1.0.1
    |   |-- <Bounce2> v2.1
    |-- <Crc16>
    |-- <AsyncMqttClient> v0.5.0
    |   |-- <ESPAsyncTCP> v1.0.1

Tried to add extra_lib_dirs pointing to .platformio/packages/framework-arduinoespressif8266/cores/esp8266/ but still no change.

Why does dependency finding works differently on these two platforms?

Because native platform uses system GCC for compilation. You can’t cross compile code for esp8266 on a x86 GCC. :slight_smile:

I’m sorry for my ignorance, but shouldn’t it be able to find the headers, and then later failing with some undefined reference to function X error?

Then I could use some mocking framework to provide valid implemnetations of those missing functions (which is exactly what I’m trying to do). What am I missing?

Edit: Tried using lib_compat_mode = 0 but result is the same.

If you are trying to mock it out and test then why bother with the native platform ?? Mock it with the actual platform. Aren’t you doing redundant work by trying to compile with the native platform and then mock it ??

@krishna_chaitanya it’s part of our TDD process to run tests natively more frequently then we run them on the device itself. We have many reasons for that:

  • Firstly device resources are fairly limited causing some large test groups to exceed it’s memory limits (strings are kept in RAM when using pio test??)

  • It consumes a lot of time to upload tests each time (for the ESP8266 it takes about 20s if uploading at high speeds)

  • Not being able to run some of the tests on native platform would make continuous integration a lot harder.

Furthermore, just ‘asserting’ things is a very poor approach to unit testing itself. This is corroborated by the fact the most test frameworks also provide some mocking framework (Ceedling provides CMock, GoogleTest, GoogleMock… etc).