-->
Page 1 of 3

Problems with std::map in ESP8266 Arduino library

PostPosted: Sat Oct 31, 2015 2:03 am
by x_arrange
Hello guys.

I'm using Arduino 1.6.5 with ESP8266 library. My goal is create map of String to store options in ESP's FS

I declare map like this:
Code: Select alltypedef std::map<String, String> Items;
Items items;


Now each way of inserting new key-value pair
Code: Select allitems["key"]="value";

or
Code: Select allitems.at("key")="value";

or
Code: Select allitems.emplace("key","value");

all leads to same result:

Arduino: 1.6.5 (Windows 8.1), Board: "Generic ESP8266 Module, Serial, 80 MHz, 40MHz, DIO, 115200, 512K (64K SPIFFS)"

pfile.cpp.o: In function `std::map<String, String, std::less<String>, std::allocator<std::pair<String const, String> > >::operator[](String&&)':
\roaming\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9\xtensa-lx106-elf\include\c++\4.8.2\bits/shared_ptr_base.h:547: undefined reference to `std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
pfile.cpp.o: In function `std::_Rb_tree<String, std::pair<String const, String>, std::_Select1st<std::pair<String const, String> >, std::less<String>, std::allocator<std::pair<String const, String> > >::_M_get_insert_unique_pos(String const&)':
\appdata\roaming\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9\xtensa-lx106-elf\include\c++\4.8.2\bits/stl_tree.h:1330: undefined reference to `std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
pfile.cpp.o: In function `Print::operator=(Print&&)':
\appdata\roaming\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9\xtensa-lx106-elf\include\c++\4.8.2\bits/stl_tree.h:1338: undefined reference to `std::_Rb_tree_increment(std::_Rb_tree_node_base*)'
pfile.cpp.o: In function `PFile::load()':
\AppData\Local\Temp\build7864248188764169690.tmp/pfile.cpp:30: undefined reference to `std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
\AppData\Local\Temp\build7864248188764169690.tmp/pfile.cpp:37: undefined reference to `std::_Rb_tree_increment(std::_Rb_tree_node_base*)'
pfile.cpp.o: In function `std::_Rb_tree<String, std::pair<String const, String>, std::_Select1st<std::pair<String const, String> >, std::less<String>, std::allocator<std::pair<String const, String> > >::_M_get_insert_hint_unique_pos(std::_Rb_tree_const_iterator<std::pair<String const, String> >, String const&)':
\appdata\roaming\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9\xtensa-lx106-elf\include\c++\4.8.2\bits/stl_tree.h:1423: undefined reference to `std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
pfile.cpp.o: In function `pair<String&&, 0u>':
\appdata\roaming\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9\xtensa-lx106-elf\include\c++\4.8.2/tuple:1088: undefined reference to `std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
collect2.exe: error: ld returned 1 exit status
Error compiling.


Does anybody has an idea how to fix it?

Re: Problems with std::map in ESP8266 Arduino library

PostPosted: Sat Feb 06, 2016 8:14 pm
by MartianMartin
I am running into this same problem right now... have you solved it?

Re: Problems with std::map in ESP8266 Arduino library

PostPosted: Sun Feb 07, 2016 5:13 am
by jcmvbkbc
MartianMartin wrote:I am running into this same problem right now... have you solved it?

Add -lstdc++ (and potentially -lsupc++) to the list of libraries to link with.

Re: Problems with std::map in ESP8266 Arduino library

PostPosted: Mon Feb 08, 2016 12:17 am
by MartianMartin
jcmvbkbc wrote:
MartianMartin wrote:I am running into this same problem right now... have you solved it?

Add -lstdc++ (and potentially -lsupc++) to the list of libraries to link with.


@jcmvbkbc I am using platformio for building and uploading. I have located the "espressif.py" build script which contains in it the lines:

Code: Select allLIBS=["c", "gcc", "phy", "pp", "net80211", "lwip", "wpa", "main",
              "json", "upgrade", "smartconfig", "pwm", "at", "ssl"],

which seems to be where I need to add a reference to the c++ standard library to get linked to. I have tried adding each of the following:
"lstdc++", "lsupc++" and "stdc++" to no avail. Am I editing the wrong file or using the wrong flags?