PlatoformIo IDE esp32 official example compiler error, pls help

Hello, my system version is ubuntu 22.04, when I installed platformIO plugin in vscode, then run the example newly created, I got the error message below. I have searched the internet for solving this, but I can’t find the solution… pls help.

#include <Arduino.h>

// put function declarations here:
int myFunction(int, int);

void setup() {
  // put your setup code here, to run once:
  int result = myFunction(2, 3);

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

// put function definitions here:
int myFunction(int x, int y) {
  return x + y;

Please show the content of the platformio.ini

; PlatformIO Project Configuration File
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
; Please visit documentation for the other options and examples

platform = espressif32
board = featheresp32
framework = arduino
monitor_speed = 115200

ok, this is auto-generated ini file content,.

platformio.ini looks good so far.

Make sure you only have 1 project open in your vs-code workspace (1)
Also make sure that the correct environment is selected (2 and 3)

yes, the step you listed I have already tested. I also run same code in my another pc, which system version is ubuntu 20.04, and it works well. So I think may not code or environment error, may the system version mismatch… Anyway, I don’t know, and I can’t solving this yet.

Sounds like a broken platform / toolchain.
Delete the espressif32 framework and packages files and have them reinstalled automatically by rebuilding the project.
Unfortunately I don’t have linux but windows.
On Windows, the files are located at C:\Users\<username>\.platformio\framework and C:\Users\<username>\.platformio\packages

Does the firmware build when you use the PIO sidebar → Build? VSCode’s Intellisense can just be off sometimes and hallucinate a problem that does not really exist.

Thanks for your reply. The files you listed, which in ubuntu located at /home/usrname/.platform. What I have done:

  1. delete /home/usrname/.platform dir.
  2. remove all plugin in vscode, then remove vscode sudo apt-get remove --purge code.
  3. install vscode.
  4. install platformIO plugin and esp32 toolchain sth.
  5. build example, same error jumped again :frowning: .
    Oh God, this bug has tormented me for a long time. Still thanks for your reply.
1 Like

Yes, I use pio sidebar build or debug button, same error. I’ve also tried executing pio build commands in terminal, didn’t work.