Cant complie with PlatformIO under VSCode

Hi there,
am trying since a day to make it work on one of my Windows PCs, i cant.
i can by following below procedure make it work on another PC (both are Windows 10 Desktops).

-install ESP IDF by the espressif online installer, tests in the powershell are working, compiles uploads etc,
-afterwards i install VSCode, and update the ESP IDF plugin with the files on the hardisk from the Espressif download on my Disk, result is i can create ESP-IDF example project, compile and upload them.
-then i install PlatformIO and it all breaks on my problem PC, cant compile anymore.
i try to make a new project or take some simple provided hello world example, nothing compiles.
“Something went wrong while trying to build the project”

ive tried to delete and reinstall all, incl python (yes i checkboc for PATH is checked), no luck so far.

having various error messages, lost the overview.
this is one
"undefined reference to app_main' c:/esp/tools/tools/xtensa-esp32s2-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s2-elf/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld.exe: esp-idf/freertos/libfreertos.a(port_common.c.obj): in function main_task’:
C:/ESP/esp-idf/components/freertos/port/port_common.c:118: undefined reference to `app_main’
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

  • The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command ninja " terminated with exit code: 1. "

it pretty much always ends with a ninja error, any ideas?
prob. easier to give up on plafromio for now and focus on the esp-idf.

if someone want to read, the full output

- Found Git: C:/ESP/tools/tools/idf-git/2.30.1/cmd/git.exe (found version "2.30.1.windows.1") 
-- ccache will be used for faster recompilation
-- The C compiler identification is GNU 8.4.0
-- The CXX compiler identification is GNU 8.4.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/ESP/tools/tools/xtensa-esp32s2-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s2-elf/bin/xtensa-esp32s2-elf-gcc.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/ESP/tools/tools/xtensa-esp32s2-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s2-elf/bin/xtensa-esp32s2-elf-gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/ESP/tools/tools/xtensa-esp32s2-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s2-elf/bin/xtensa-esp32s2-elf-g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Project is not inside a git repository, or git repository has no commits; will not use 'git describe' to determine PROJECT_VER.
-- Building ESP-IDF components for target esp32s2
-- Project sdkconfig file C:/ESP32-S2/piotestx/sdkconfig
-- Found Python3: C:/ESP/tools/python_env/idf4.4_py3.8_env/Scripts/python.exe (found version "3.8.7") found components: Interpreter 
-- Performing Test C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS
-- Performing Test C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS - Success
-- App "piotestx" version: 1
-- Adding linker script C:/ESP32-S2/piotestx/build/esp-idf/esp_system/ld/memory.ld
-- Adding linker script C:/ESP/esp-idf/components/esp_system/ld/esp32s2/sections.ld.in
-- Adding linker script C:/ESP/esp-idf/components/esp_rom/esp32s2/ld/esp32s2.rom.ld
-- Adding linker script C:/ESP/esp-idf/components/esp_rom/esp32s2/ld/esp32s2.rom.api.ld
-- Adding linker script C:/ESP/esp-idf/components/esp_rom/esp32s2/ld/esp32s2.rom.libgcc.ld
-- Adding linker script C:/ESP/esp-idf/components/esp_rom/esp32s2/ld/esp32s2.rom.newlib-funcs.ld
-- Adding linker script C:/ESP/esp-idf/components/esp_rom/esp32s2/ld/esp32s2.rom.newlib-data.ld
-- Adding linker script C:/ESP/esp-idf/components/esp_rom/esp32s2/ld/esp32s2.rom.spiflash.ld
-- Adding linker script C:/ESP/esp-idf/components/esp_rom/esp32s2/ld/esp32s2.rom.newlib-time.ld
-- Adding linker script C:/ESP/esp-idf/components/soc/esp32s2/ld/esp32s2.peripherals.ld
-- Components: app_trace app_update asio bootloader bootloader_support bt cbor cmock coap console cxx driver efuse esp-tls esp32s2 esp_adc_cal esp_common esp_eth esp_event esp_gdbstub esp_hid esp_http_client esp_http_server esp_https_ota esp_https_server esp_hw_support esp_ipc esp_lcd esp_local_ctrl esp_netif esp_phy esp_pm esp_ringbuf esp_rom esp_serial_slave_link esp_system esp_timer esp_websocket_client esp_wifi espcoredump esptool_py expat fatfs freemodbus freertos hal heap idf_test ieee802154 jsmn json libsodium log lwip mbedtls mdns mqtt newlib nghttp nvs_flash openssl openthread partition_table perfmon protobuf-c protocomm pthread sdmmc soc spi_flash spiffs tcp_transport tcpip_adapter tinyusb touch_element ulp unity usb vfs wear_levelling wifi_provisioning wpa_supplicant xtensa
-- Component paths: C:/ESP/esp-idf/components/app_trace C:/ESP/esp-idf/components/app_update C:/ESP/esp-idf/components/asio C:/ESP/esp-idf/components/bootloader C:/ESP/esp-idf/components/bootloader_support C:/ESP/esp-idf/components/bt C:/ESP/esp-idf/components/cbor C:/ESP/esp-idf/components/cmock C:/ESP/esp-idf/components/coap C:/ESP/esp-idf/components/console C:/ESP/esp-idf/components/cxx C:/ESP/esp-idf/components/driver C:/ESP/esp-idf/components/efuse C:/ESP/esp-idf/components/esp-tls C:/ESP/esp-idf/components/esp32s2 C:/ESP/esp-idf/components/esp_adc_cal C:/ESP/esp-idf/components/esp_common C:/ESP/esp-idf/components/esp_eth C:/ESP/esp-idf/components/esp_event C:/ESP/esp-idf/components/esp_gdbstub C:/ESP/esp-idf/components/esp_hid C:/ESP/esp-idf/components/esp_http_client C:/ESP/esp-idf/components/esp_http_server C:/ESP/esp-idf/components/esp_https_ota C:/ESP/esp-idf/components/esp_https_server C:/ESP/esp-idf/components/esp_hw_support C:/ESP/esp-idf/components/esp_ipc C:/ESP/esp-idf/components/esp_lcd C:/ESP/esp-idf/components/esp_local_ctrl C:/ESP/esp-idf/components/esp_netif C:/ESP/esp-idf/components/esp_phy C:/ESP/esp-idf/components/esp_pm C:/ESP/esp-idf/components/esp_ringbuf C:/ESP/esp-idf/components/esp_rom C:/ESP/esp-idf/components/esp_serial_slave_link C:/ESP/esp-idf/components/esp_system C:/ESP/esp-idf/components/esp_timer C:/ESP/esp-idf/components/esp_websocket_client C:/ESP/esp-idf/components/esp_wifi C:/ESP/esp-idf/components/espcoredump C:/ESP/esp-idf/components/esptool_py C:/ESP/esp-idf/components/expat C:/ESP/esp-idf/components/fatfs C:/ESP/esp-idf/components/freemodbus C:/ESP/esp-idf/components/freertos C:/ESP/esp-idf/components/hal C:/ESP/esp-idf/components/heap C:/ESP/esp-idf/components/idf_test C:/ESP/esp-idf/components/ieee802154 C:/ESP/esp-idf/components/jsmn C:/ESP/esp-idf/components/json C:/ESP/esp-idf/components/libsodium C:/ESP/esp-idf/components/log C:/ESP/esp-idf/components/lwip C:/ESP/esp-idf/components/mbedtls C:/ESP/esp-idf/components/mdns C:/ESP/esp-idf/components/mqtt C:/ESP/esp-idf/components/newlib C:/ESP/esp-idf/components/nghttp C:/ESP/esp-idf/components/nvs_flash C:/ESP/esp-idf/components/openssl C:/ESP/esp-idf/components/openthread C:/ESP/esp-idf/components/partition_table C:/ESP/esp-idf/components/perfmon C:/ESP/esp-idf/components/protobuf-c C:/ESP/esp-idf/components/protocomm C:/ESP/esp-idf/components/pthread C:/ESP/esp-idf/components/sdmmc C:/ESP/esp-idf/components/soc C:/ESP/esp-idf/components/spi_flash C:/ESP/esp-idf/components/spiffs C:/ESP/esp-idf/components/tcp_transport C:/ESP/esp-idf/components/tcpip_adapter C:/ESP/esp-idf/components/tinyusb C:/ESP/esp-idf/components/touch_element C:/ESP/esp-idf/components/ulp C:/ESP/esp-idf/components/unity C:/ESP/esp-idf/components/usb C:/ESP/esp-idf/components/vfs C:/ESP/esp-idf/components/wear_levelling C:/ESP/esp-idf/components/wifi_provisioning C:/ESP/esp-idf/components/wpa_supplicant C:/ESP/esp-idf/components/xtensa
-- Configuring done
-- Generating done
-- Build files have been written to: C:/ESP32-S2/piotestx/build
Adding "set-target"'s dependency "fullclean" to list of commands with default set of options.
Executing action: fullclean
Build directory 'c:\esp32-s2\piotestx\build' not found. Nothing to clean.
Executing action: set-target
Set Target to: esp32s2, new sdkconfig created. Existing sdkconfig renamed to sdkconfig.old.
Running cmake in directory c:\esp32-s2\piotestx\build
Executing "cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DESP_PLATFORM=1 -DIDF_TARGET=esp32s2 -DCCACHE_ENABLE=1 c:\esp32-s2\piotestx"...
idf_versions.txt has (1) KB
idf_versions.txt progress: 100.00% (0.08 / 0.08) KB
Using existing c:\ESP\tools\dist\idf-git-2.30.1-win64.zip
Installing c:\ESP\tools\tools\idf-git\2.30.1 ...
Warning File c:\ESP\tools\tools\idf-git\2.30.1\cmd\git.exe
                                        already exists and was not updated.
Warning File c:\ESP\tools\tools\idf-git\2.30.1\dev\_._
                                        already exists and was not updated.
Warning File c:\ESP\tools\tools\idf-git\2.30.1\etc\bash.bash_logout
                                        already exists and was not updated.
Warning File c:\ESP\tools\tools\idf-git\2.30.1\etc\bash.bashrc
                                        already exists and was not updated.
Warning File c:\ESP\tools\tools\idf-git\2.30.1\etc\fstab
                                        already exists and was not updated.
Warning File c:\ESP\tools\tools\idf-git\2.30.1\etc\gitattributes
                                        already exists and was not updated.
Warning File c:\ESP\tools\tools\idf-git\2.30.1\etc\msystem
                                        already exists and was not updated.
Warning File c:\ESP\tools\tools\idf-git\2.30.1\etc\nsswitch.conf
                                        already exists and was not updated.
Warning File c:\ESP\tools\tools\idf-git\2.30.1\etc\profile
                                        already exists and was not updated.
Extracted c:\ESP\tools\tools\idf-git\2.30.1 ...
Using existing c:\ESP\tools\tools\idf-python\3.8.7

Downloading Toolchain for Xtensa (ESP32) based on GCC
Found xtensa-esp32-elf in c:\ESP\tools\dist
Downloading Toolchain for Xtensa (ESP32-S2) based on GCC
Found xtensa-esp32s2-elf in c:\ESP\tools\dist
Downloading Toolchain for Xtensa (ESP32-S3) based on GCC
Found xtensa-esp32s3-elf in c:\ESP\tools\dist
Downloading Toolchain for 32-bit RISC-V based on GCC
Found riscv32-esp-elf in c:\ESP\tools\dist
Downloading Toolchain for ESP32 ULP coprocessor
Found esp32ulp-elf in c:\ESP\tools\dist
Downloading Toolchain for ESP32-S2 and ESP32-S3 ULP coprocessors
Found esp32s2ulp-elf in c:\ESP\tools\dist
Downloading CMake build system
Found cmake in c:\ESP\tools\dist
Downloading OpenOCD for ESP32
Found openocd-esp32 in c:\ESP\tools\dist
Downloading Ninja build system
Found ninja in c:\ESP\tools\dist
Downloading IDF wrapper tool for Windows
Found idf-exe in c:\ESP\tools\dist
Downloading Ccache (compiler cache)
Found ccache in c:\ESP\tools\dist
Downloading dfu-util (Device Firmware Upgrade Utilities)
Found dfu-util in c:\ESP\tools\dist

Using existing Toolchain for Xtensa (ESP32) based on GCC in c:\ESP\tools\tools\xtensa-esp32-elf\esp-2021r2-patch3-8.4.0
Using existing Toolchain for Xtensa (ESP32-S2) based on GCC in c:\ESP\tools\tools\xtensa-esp32s2-elf\esp-2021r2-patch3-8.4.0
Using existing Toolchain for Xtensa (ESP32-S3) based on GCC in c:\ESP\tools\tools\xtensa-esp32s3-elf\esp-2021r2-patch3-8.4.0
Using existing Toolchain for 32-bit RISC-V based on GCC in c:\ESP\tools\tools\riscv32-esp-elf\esp-2021r2-patch3-8.4.0
Using existing Toolchain for ESP32 ULP coprocessor in c:\ESP\tools\tools\esp32ulp-elf\2.28.51-esp-20191205
Using existing Toolchain for ESP32-S2 and ESP32-S3 ULP coprocessors in c:\ESP\tools\tools\esp32s2ulp-elf\2.28.51-esp-20191205
Using existing CMake build system in c:\ESP\tools\tools\cmake\3.20.3
Using existing OpenOCD for ESP32 in c:\ESP\tools\tools\openocd-esp32\v0.11.0-esp32-20211220
Using existing Ninja build system in c:\ESP\tools\tools\ninja\1.10.2
Using existing IDF wrapper tool for Windows in c:\ESP\tools\tools\idf-exe\1.0.3
Using existing Ccache (compiler cache) in c:\ESP\tools\tools\ccache\4.3
Using existing dfu-util (Device Firmware Upgrade Utilities) in c:\ESP\tools\tools\dfu-util\0.9

Requirement already satisfied: virtualenv in c:\esp\tools\tools\idf-python\3.8.7\lib\site-packages (20.4.0)
Requirement already satisfied: distlib<1,>=0.3.1 in c:\esp\tools\tools\idf-python\3.8.7\lib\site-packages (from virtualenv) (0.3.1)
Requirement already satisfied: appdirs<2,>=1.4.3 in c:\esp\tools\tools\idf-python\3.8.7\lib\site-packages (from virtualenv) (1.4.4)
Requirement already satisfied: six<2,>=1.9.0 in c:\esp\tools\tools\idf-python\3.8.7\lib\site-packages (from virtualenv) (1.15.0)
Requirement already satisfied: filelock<4,>=3.0.0 in c:\esp\tools\tools\idf-python\3.8.7\lib\site-packages (from virtualenv) (3.0.12)
WARNING: You are using pip version 20.3.3; however, version 22.1.2 is available.
You should consider upgrading via the 'c:\ESP\tools\tools\idf-python\3.8.7\python.exe -m pip install --upgrade pip' command.


PermissionError: [WinError 5] Zugriff verweigert: 'C:\\ESP\\tools\\python_env\\idf4.4_py3.8_env\\Scripts\\python.exe'
Command failed: "c:\ESP\tools\tools\idf-python\3.8.7\python.exe" -m virtualenv "c:\ESP\tools\python_env\idf4.4_py3.8_env" -p "c:\ESP\tools\tools\idf-python\3.8.7\python.exe"
Command failed: "c:\ESP\tools\tools\idf-python\3.8.7\python.exe" -m virtualenv "c:\ESP\tools\python_env\idf4.4_py3.8_env" -p "c:\ESP\tools\tools\idf-python\3.8.7\python.exe"

this is when trying to configure the esp.idf plugin.
Command failed: “c:\ESP\tools\tools\idf-python\3.8.7\python.exe” “c:\ESP\esp-idf\tools\idf_tools.py” install-python-env ERROR: Command errored out with exit status 1: command:

its strange, the python enviroment seems to be ok as the esp-idf themself can compile… as long i dont install PlatformIO.

If you disable the PlatformIO extension in VSCode for your workspace, does it still fail?

1 Like

good point!
i uninstalled the PIO extension (not disabled).
then i tried to configure the esp-idf extension.

still the same.
Command failed: “c:\ESP\tools\tools\idf-python\3.8.7\python.exe” “c:\ESP\esp-idf\tools\idf_tools.py” install-python-env ERROR: Command errored out with exit status 1: command:

broken, need a complete reinstall and avoid PIO to make it work for me.

i have esp-idf working in vscode again.
easiest for me was to delete and resinstall all as good i can.
its still a a miracle to me whats going on there.
its realted to my system as the same constelation works on another PC, i just dont know what to change anymore, also rthat PIO breaks my esp-idf installation everytime is a bit concerning.

to answer directly, yes it does.

btw the error seems somehow unrelated to the system wide installed python (3.10 used).
could it make sense to try to update the esp-idf supplied python to a newer version?
i updated pip, but that seems to have no effect,i may could try to update the whole python maybe?