Writing/Uploading C++ code on wifi rev2

Hi Guys,

I am confused on this.

We are trying to upload/flash C++ code on Arduino wifi Rev2 board and we are getting some problems. Problems like :

Processing uno_wifi_rev2 (platform: atmelmegaavr; board: uno_wifi_rev2; framework: arduino; lib_deps: knolleary/PubSubClient@^2.8)
CONFIGURATION: https://docs.platformio.org/page/boards/atmelmegaavr/uno_wifi_rev2.html
PLATFORM: Atmel megaAVR (1.5.0) > Arduino Uno WiFi Rev2
HARDWARE: ATMEGA4809 16MHz, 6KB RAM, 47.50KB Flash
 - framework-arduino-megaavr 1.8.7 
 - toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <PubSubClient> 2.8.0 (/home/hemant/Remote_Operation_ESP32/.pio/libdeps/uno_wifi_rev2/PubSubClient)
Building in release mode
avr-g++ -o .pio/build/uno_wifi_rev2/src/cust_libs/led.cpp.o -c -std=gnu++11 -fno-exceptions -fno-threadsafe-statics -fpermissive -Wno-error=narrowing -Os -w -ffunction-sections -fdata-sections -flto -mmcu=atmega4809 -DPLATFORMIO=50205 -DARDUINO_AVR_UNO_WIFI_REV2 -DUNO_WIFI_REV2_328MODE -DMILLIS_USE_TIMERB3 -DF_CPU=16000000L -DARDUINO_ARCH_MEGAAVR -DARDUINO=10808 -DUSB_VID=0x03eb -DUSB_PID=0x2145 "-DUSB_PRODUCT=\"Arduino Uno WiFi Rev2\"" -DUSB_MANUFACTURER=\"Arduino\" -Iinclude -Isrc -I.pio/libdeps/uno_wifi_rev2/PubSubClient/src -I/home/hemant/.platformio/packages/framework-arduino-megaavr/cores/arduino/api/deprecated -I/home/hemant/.platformio/packages/framework-arduino-megaavr/cores/arduino -I/home/hemant/.platformio/packages/framework-arduino-megaavr/variants/uno2018 src/cust_libs/led.cpp
src/cust_libs/led.cpp:15:10: fatal error: iostream: No such file or directory
 #include <iostream>
compilation terminated.

As you can see, compiler which is getting used for this process is avr-g++ which might not be supporting the library. Questions are:

Why does it not support?
How can we resolve this?

Thanks in advance. I would be happy to write more details if needed.

P.S. I havn't written detailed code since I thought error is self explanatory.

Because that library doesn't make sense on a microcontroller.

Remove that line and maybe every other line referring to iostreams.

As you failed to post your code we cannot check if there are other mistakes in your code.

Not quite. The AVR cpus used on most Arduinos has a compiler that supports the C++ language, but it lacks the normal C++ libraries - the full C++ libraries are full of stuff (execeptions, dynamic allocation, filesystems, assumption of ample RAM) that either "don't make sense" or are difficult to impossible to implement on that class of CPU.

There have been some efforts to implement at least parts of the library and STL, but it would take an enormous amount of effort to port and maintain all of it.

iostream, OTOH, is no less sensible than Arduino's print functions (at least, as long as you're talking about output to cout.) Various people have added cout support over the years, and you can add their support via the Arduino library manger (or presumably something similar in platformio.) For example, see: ArduinoSTL - Arduino Reference

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.