To_string is not a member of std

Hi to all, I’m new to platformIO and Im trying to use tensorflow lite in the esp32-CAM (using this TensorFlow Lite With and the ESP32 - YouTube ). When I compile the program I only got his 2 errors:

error: ‘to_string’ is not a member of ‘std’.

I search in the forum for someone with this error and found this Error: 'to_string' is not a member of 'std'
But is not solved it.
I guess is something with the compiler, I’m using xtensa-esp32-elf-gcc as C/c++ compiler (by default).
Im using PlatformIO in linux tumbleweed machine.

Interesting, I don’t even get to that point because the TensorFlow Lite library not installed

Compiling .pio/build/esp32dev/src/NeuralNetwork.cpp.o
src/NeuralNetwork.cpp:3:52: fatal error: tensorflow/lite/micro/all_ops_resolver.h: No such file or directory

Can you upload the exact tensorflow package that you’re using? I see it’s pointing at GitHub - atomic14/platformio-tensorflow-lite: Easily extract the tfmicro framework for use in but there’s quite a few configuration possibilities for tensor flow and ESP-IDF branch versions possible.

Hi maxgerhardt,
I’m using the tfmicro folder thats is generated by compiling one of the examples in the tensorflow. The only 2 errors I got is those I posted in here. I tried changing the compilers in PlatformIO but is not working.

I have the same problem with Teensy 4.x and 3.x. On Teensy it is caused by an old version of gcc.

1 Like

in the C/C++ configuration I got:
for C standard : c17
for C++ standard : c++20
compiler path: /home/gaston/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gcc
I tried with others path in there to solve this errors, but none of them works (clang, clang++,gcc,g++ etc)
the erros is : lib/tfmicro/tensorflow/lite/kernels/ error: ‘to_string’ is not a member of ‘std’
when i open the error in the editor this line are marked:

And with what exact command did you do that? The build is failing for me.

I have a feeling that the used tensor version, together with what C++ standardlib features it uses, greatly influences this error. That is, in conjuction with the used toolchain (toolchain-xtensa32) and C++ standard version.

Have you for fun tried the 8.4.0 toolchain instead of the standard 5.2.0 by using

platform_packages =

in the platformio.ini?

example to generate the tfmicro (2019) you need to change the tfmicro when you add it to the lib in the platformIO.
I tried to use

platform_packages =

but the errors still there

Indeed when I try and compile the code

#include <Arduino.h>
#include <string>

void setup() {
  std::string test = std::to_string(123);
  //should be "123" now.
  Serial.println("Test is: " + String(test.c_str()));

void loop() {


platform = espressif32
board = esp32dev
framework = arduino

I get

Compiling .pio\build\esp32dev\src\main.cpp.o
src\main.cpp: In function 'void setup()':
src\main.cpp:5:22: error: 'to_string' is not a member of 'std'
   std::string test = std::to_string(123);
*** [.pio\build\esp32dev\src\main.cpp.o] Error 1

However when I add

platform_packages =

to the platformio.ini I get

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Espressif 32 (3.1.0) > Espressif ESP32 Dev Module
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)
 - framework-arduinoespressif32 0.0.0+sha.371f382
 - tool-esptoolpy 1.30000.201119 (3.0.0)
 - toolchain-xtensa32 2.80400.210114 (8.4.0)
LDF: Library Dependency Finder ->
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 32 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\esp32dev\src\main.cpp.o
Indexing .pio\build\esp32dev\libFrameworkArduino.a
Linking .pio\build\esp32dev\firmware.elf
Retrieving maximum program size .pio\build\esp32dev\firmware.elf
Building .pio\build\esp32dev\firmware.bin
Checking size .pio\build\esp32dev\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   4.4% (used 14436 bytes from 327680 bytes)
Flash: [==        ]  17.3% (used 226976 bytes from 1310720 bytes) v3.0
================== [SUCCESS] Took 11.83 seconds ================== 

so the newest compiler + Arduino core work for me and std::to_string() is available… But this is surely not how it’s supposed to work. Surely the wrong TensorFlow library version must be at use here. I hope for an update in my opened issues soon.

If i use :
platform_packages = toolchain-xtensa32@~2.80400.0 framework-arduinoespressif32@

I got this error on PlatformIO:

command '' not found

this is my platformio.ini:

platform = espressif32
board = esp32cam
framework = arduino
monitor_speed = 115200
platform_packages =
framework-arduinoespressif32@GitHub - espressif/arduino-esp32: Arduino core for the ESP32

there’s something wrong with my setup.
P.S: funny thing, I can use platformio to program the esp32. I can’t use arduino to program the esp32 due to pyserial not found.

It’s probably doing an internal tasks rebuild and you clicked on build too fast. Try reopening VSCode and let the tasks fully reload, this may take some time due to arduino-esp32 being downloaded via git.

its working. I remove this line:
and now its working. I didn’t find an update on tensorflow with platformio, only a video (2020) and the guy who did it, din’t answer my question about those errors.

Can you upload the whole working project for future reference for others?

sure why not. But you also was able to compile it rigth?

No, only my minimal example with std::to_string() above, not the tensorflow example, since I can’t get the TensorFlow library to build.

I upload the file in repository GitHub (i tried to do it in here but it was to large the file).
The name is TF-ESP32-Platformio. Let me know if you are able to find it. By the way is the first repository I made, let me know if I have to add something else in there to help others.

Yep I see it under GitHub - GastonMelo/TF-ESP32-Platformio: TensorFlow Lite With and the ESP32 :+1:

The repository at GitHub - atomic14/tensorflow-lite-esp32: SImple example getting TensorFlow Lite up and running on the ESP32 with has been updated and now I can build using all standard versions (normal latest release version of Arduino-ESP32, normal 5.4.0 compiler), so you should have no problems now.