Unable to compile for esp32 board in arduino ide

Hi! Everyone, Hoping everyone is doing well, I often use arduino ide for esp32 programming but this time I'm facing an un expected error "Error compiling for board ESP32 Dev Module". I tried every possible solution (re-installed the ide software, re-installing of esp32 board etc.) but failed to figure out the issue. Even, I'm getting the same error for simplest code which is compiling for other arduino boards (Mega, UNO, Nano, Leonardo etc.). If someone have the solution please share to fix the error. The following code isn't compiling too and generating the error for esp32 board.

void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}

Your comments are valuable for beginners and will be appreciated. Thanks in advance.
The complete error I'm facing is given below:

Arduino: 1.8.18 (Windows 10), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"

In file included from c:\programdata\matlab\supportpackages\r2019a\3p.instrset\arduinoide.instrset\idepkgs\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0\algorithm:60:0,

             from C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\arduinoide.instrset\idepkgs\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Arduino.h:142,

             from sketch\sketch_dec21a.ino.cpp:1:

c:\programdata\matlab\supportpackages\r2019a\3p.instrset\arduinoide.instrset\idepkgs\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0\utility:68:28: fatal error: bits/c++config.h: No such file or directory

compilation terminated.

exit status 1

Error compiling for board ESP32 Dev Module.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

@shahzadhamid, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project :wink: See About the Installation & Troubleshooting category.

Have you done a search for e.g. bits/c++config.h? From memory, I have seen a similar problem recently.

Hi @shahzadhamid

I'm not positive (or negative for that matter either :grinning_face_with_smiling_eyes:), but I think that is from a corrupted board directory. Try going to the boards list and uninstalling ESP32. Then in the IDE, go to Arduino / Preferences. In there, find the name "Additional Boards Manager URLs". Paste this link there:
https://dl.espressif.com/dl/package_esp32_index.json
Then hit OK, and restart the IDE. This might fix it, or it might not. But it might be worth a try.

thanks for your suggestion. Yes, I searched for this but unable to understand properly. I'm an electrical engineering student and not very good in programming, that's why I feel difficulties to understand the complex code.

Hi @kgray9 thanks for your reply, tried multiple times the same but got the same error. Even I uninstalled the ide and face the same error after pasting the link in preferences and installing latest version 1.0.6 for esp32 board.

Hi @shahzadhamid
On my notebook (win10) the file "c++config.h" is in the folder:

C:\Users\XXXXX\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-80-g6c4433a-5.2.0\xtensa-esp32-elf\include\c++\5.2 .0\xtensa-esp32-elf\bits

where I put XXXXX is the username.

Search your PC if this folder sequence exists and if the file is in this location.

I searched and there is a preferences text document present in Arduino 15 folder, nothing else, the sequence of my folders exists is:

C:\Users\XXXXXX\AppData\Local\Arduino15

Hi
I think these folders are created when installing ESP32.

How did you install ESP32 in your IDE?

Ref: Installing ESP32 in Arduino IDE (Windows, Mac OS X, Linux) | Random Nerd Tutorials

Yes, @ruilviana , I used the same site (Random Nerd Tutorials) for installing ESP32. I used same previously and everything worked fine but this time I re-installed multiple times but facing same error.

By the way, here is the location where the file "c++config.h" exist in my system.

C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\arduinoide.instrset\idepkgs\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0\xtensa-esp32-elf\bits

Hi
Strange, if the file exists, as the IDE can't find it.

"Your error msg"
c:\programdata\matlab\supportpackages\r2019a\3p.instrset\arduinoide.instrset\idepkgs\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0\utility:68:28: fatal error: bits/c++config.h: No such file or directory

Hi
There is a difference in the way.

include\c++\5.2.0\xtensa-esp32-elf\bits <<<<,---->>>> include\c++\5.2.0\utility:

Yes, I just noticed the difference but the header file exists at location as i shared. I don't know why the ide is unable to locate. it worked fine in the past. this time i changed my PC and facing the issue