Espressif8266 platform, arduino framework and stdlib (fatal error: features.h: No such file or directory)

Hi all,
I’ve just installed platformio on my linux ubuntu env+vscode, but I’ve some dependencies problem at compile time. I was able to compile the same platform using Arduino IDE without problems.

Error seems to be related to stdlib and the features.h headers file, but I’m not completely sure how the deps need to be handled.

Here the screenshot with the verbose build output log and my platformio.ini file (the project is the one generated by the “new project” dialog, without any other edits) …

Did someone already faced this issue? I’ve already tried searching on the web finding others with deps issue towards the stdlib … but nothing specific to platformio.


Something is going extremely wrong there. Arduino.h tries to include stdlib.h, which should be in the xtensa compiler’s include folder somewhere in ~/.platformio/packages/toolchain-xtensa/include, but it ends up in the Linux’s system’s headers (for x64) in /usr/include. It should never go in there.

As a first defense mechanism, please

rm -rf ~/.platformio/packages/toolchain-xtensa
rm -rf ~/.platformio/.cache

and then build the project again. PlatformIO should redownload the toolchain and try again.

1 Like

Thanks @maxgerhardt for your prompt reply.

So, I removed both the toolchain and .cache dirs and as expected the Tool Manager redownloaded the packages needed but it ended up with the same error.

So I decided to have a look into my env variables finding this one:


that actually affects how gnu compiler operates.

I found it specified in my .zshrc file as a workaround to address some other issue with nvim-lsp (the component that allows nvim editor to ‘talk’ with an LSP server).

BTW, when removed the variable I was able to compile correctly the platform with the xtensa toolchain.

Oh wow. I thought the PlatformIO would counteract that by launching the xtensa gcc executable in a clean environment that’s devoid of any user variables. Apparently it does not. Can you file a bug at that, in the case the user has the CPLUS_INCLUDE_PATH environment variable set, it breaks compilation of firmwares?