ESP32 not compiling on windows. bits/c++config.h: No such file or directory

Hello all,
I use PIO since a few month and I am far from an expert.
I wrote lots of tests and a few nice projects on ESp32 and I was happy with it.
I updated my windows PC to Windows 10 a few weeks ago. Reinstalled arduino IDE, VS code, PIO…
Since then, my program don’t compile as the file bits/c++config.h is missing.

It doesn’t compile even with an empty “main.cpp” file just including <arduino.h> (ESP32 board)

I tried with other platform (teensy) as I saw this problem occured too. Everything is OK with teensy.

I deleted the old pio file and rebuilt. But everythinf ended with : fatal error: bits/c++config.h: No such
file or directory.

Here is what tells the terminal :

Processing esp32doit-devkit-v1 (platform: espressif32; board: esp32doit-devkit-v1; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32doit-devkit-v1.html
PLATFORM: Espressif 32 (2.1.0) > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 3.10004.201016 (1.0.4)
 - tool-esptoolpy 1.30000.201119 (3.0.0)
 - toolchain-xtensa32 2.50200.80 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 34 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <AsyncTCP> 1.1.1
|-- <Adafruit BME280 Library> 2.1.2    
|   |-- <Adafruit Unified Sensor> 1.1.4
|   |-- <SPI> 1.0
|   |-- <Wire> 1.0.1
|-- <Adafruit Unified Sensor> 1.1.4    
|-- <ESP_WiFiManager> 1.3.0
|   |-- <ESP_DoubleResetDetector> 1.1.1
|   |   |-- <LittleFS_esp32> 1.0.5
|   |   |   |-- <FS> 1.0
|   |   |-- <SPIFFS> 1.0
|   |   |   |-- <FS> 1.0
|   |   |-- <FS> 1.0
|   |-- <LittleFS_esp32> 1.0.5
|   |   |-- <FS> 1.0
|   |-- <WiFi> 1.0
|-- <Tone32> 1.0.0
|-- <I2C Temperature Sensors derived from the LM75> 1.0.3
|   |-- <Wire> 1.0.1
|-- <FS> 1.0
|-- <SPI> 1.0
|-- <SPIFFS> 1.0
|   |-- <FS> 1.0
|-- <WiFi> 1.0
|-- <Wire> 1.0.1
Building in release mode
Compiling .pio\build\esp32doit-devkit-v1\src\main.cpp.o
In file included from c:\users\thomas\.platformio\packages\toolchain-xtensa32@2.50200.80\xtensa-esp32-elf\include\c++\5.2.0\algorithm:60:0,
                 from C:/Users/thomas/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:142,
                 from src\main.cpp:9:
c:\users\thomas\.platformio\packages\toolchain-xtensa32@2.50200.80\xtensa-esp32-elf\include\c++\5.2.0\utility:68:28: fatal error: bits/c++config.h: No such 
file or directory
compilation terminated.
Compiling .pio\build\esp32doit-devkit-v1\lib22f\AsyncTCP\AsyncTCP.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib7c7\Adafruit Unified Sensor\Adafruit_Sensor.cpp.o
In file included from c:\users\thomas\.platformio\packages\toolchain-xtensa32@2.50200.80\xtensa-esp32-elf\include\c++\5.2.0\algorithm:60:0,
                 from C:\Users\thomas\.platformio\packages\framework-arduinoespressif32\cores\esp32/Arduino.h:142,
                 from .pio\libdeps\esp32doit-devkit-v1\AsyncTCP\src\AsyncTCP.cpp:22:
c:\users\thomas\.platformio\packages\toolchain-xtensa32@2.50200.80\xtensa-esp32-elf\include\c++\5.2.0\utility:68:28: fatal error: bits/c++config.h: No such 
file or directory
compilation terminated.
Archiving .pio\build\esp32doit-devkit-v1\lib58e\libSPI.a
*** [.pio\build\esp32doit-devkit-v1\src\main.cpp.o] Error 1
*** [.pio\build\esp32doit-devkit-v1\lib22f\AsyncTCP\AsyncTCP.cpp.o] Error 1
In file included from c:\users\thomas\.platformio\packages\toolchain-xtensa32@2.50200.80\xtensa-esp32-elf\include\c++\5.2.0\algorithm:60:0,
                 from C:\Users\thomas\.platformio\packages\framework-arduinoespressif32\cores\esp32/Arduino.h:142,
                 from .pio\libdeps\esp32doit-devkit-v1\Adafruit Unified Sensor\Adafruit_Sensor.h:26,
                 from .pio\libdeps\esp32doit-devkit-v1\Adafruit Unified Sensor\Adafruit_Sensor.cpp:1:
c:\users\thomas\.platformio\packages\toolchain-xtensa32@2.50200.80\xtensa-esp32-elf\include\c++\5.2.0\utility:68:28: fatal error: bits/c++config.h: No such 
file or directory
compilation terminated.
*** [.pio\build\esp32doit-devkit-v1\lib7c7\Adafruit Unified Sensor\Adafruit_Sensor.cpp.o] Error 1
================================================================ [FAILED] Took 2.74 seconds ================================================================

Please remove all folders of the form c:\users\thomas\.platformio\packages\toolchain-xtensa32* and retry compilation. Seems like your toolchain download is broken.

Hello Max,
That was the way to go. Everything is going fine now.
I thank you very much !

@maxgerhardt There’s quite a number of similar issues where the packages seem to be incomplete or otherwise broken. Could this be a systematic issue or bug?

1 Like

One could definitely open an issue in the core to have some checking for a good/non-corrupted downloaded content there, with hashes / checksums etc. But it would still have to allow for modifications of the unpacked files if users wish so, which would be tricky. Also with the antivirus systems and sandboxing techniques of today, an AV could really fool an application being run that the file it is unpacking are there when they are actually emulated and not really ending up in the real file system.

The interesting question would be what causes all that. Bad internet connection of users? Bad server-side internet from the content distribution network side? Intermittent drops? AVs interfering?

I had the same problem after I had to switch to a new PC. After a day of searching I came across this thread and lo and behold, uninstall platformio, delete, reinstall and everything works perfectly.