Collect2.exe: error: ld returned 1 exit status, in ESP32 but ok in STM32

I have a project targeting ESP32 platform using arduino frameworks. My co-worker ported it to STM32 and broke the ESP32 compatibility.

As I try to fix it, an error that is not present before showed up:

error: 'to_string' is not a member of 'std'

A few mouth ago I was able to compile for ESP32 without this ERROR. After searching this forum, I fixed this by adding:

platform_packages =
    platformio/framework-arduinoespressif32 @  

The 2nd line in platform_packages was always there. Just the 1st line was added. this fixed the std::to_string error.

But at linking I got:

collect2.exe: error: ld returned 1 exit status

As this compiles of for STM32, I think this may not be a problem in the code.

Do you guys know the way out?

  1. Arduino core 2.0.0 support is not stable yet and the above platform_packages is a hack (Support for the latest Arduino v2.0 · Issue #619 · platformio/platform-espressif32 · GitHub)
  2. Using the 8.4.2 compiler from the PlatformIO repositories did not work me when using 2.0.0, see Use different version of Arduino framework on espressif platform - #6 by maxgerhardt
  3. If it stills fail at linking, check if std::to_string works in the Arduino-IDE for Arduino-ESP32. If it also fails → bug report to Arduino-ESP32, work-around std::to_string usage (e.g., construct a simple Arduino String object from the to-be-converted parameter, then .c_str() it). If it works in the Arduino-IDE, wait for proper Arduino core 2.0.0 integration or avoid std::to_string usage.

Thank you for the help.

One strange thing to note is that, this code worked on ESP32 a few mouth ago, with std::to_string.

But back then I was using:

platform_packages =
  ; use a special branch
  framework-arduinoespressif32 @

but this does not work now as I got:
fatal: Remote branch idf-release/v4.0 not found in upstream origin
That’s why I changed to , the #2.0.0 does not matter, remove it will produce same result.

Correct, they deleted it, but someone backed it up at framework-arduinoespressif32 @

Great thanks, I was able to build finally, using this

platform_packages =
    framework-arduinoespressif32 @