c++libstdc++esp8266sming

Is there a way to use std::map in Sming IDE (ESP8266)?


I'm trying to use std::map in ESP8266 firmware developing with Sming 2.1.0 (on Windows 7 SP1) . I've got following error:

undefined reference to `std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'

According to this http://www.esp8266.com/viewtopic.php?p=40593 and this ESP8266 for Arduino IDE (xtensa-lx106-elf-gcc) and std::map linking error one should add -lstdc++ (and potentially -lsupc++) to the list of libraries to link with.

But in Makefile-project.mk in Sming there is -nostdlib flag!

LDFLAGS = -nostdlib ...

If I change it to -lstdc++ -lsupc++ I've got those errors instead:

c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/5.1.0/../../../../xtensa-lx106-elf/bin/ld.exe: cannot find crt1-sim.o: No such file or directory
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/5.1.0/../../../../xtensa-lx106-elf/bin/ld.exe: cannot find _vectors.o: No such file or directory

And to solve this here https://www.reddit.com/r/esp8266/comments/3pmyx8/trying_to_link_but_getting_weird_errors/ recommended following:

Try using the -nostdlib link option.

Brilliant!

I've tried to use xtensa-lx106-elf from arduino-esp8266 https://github.com/rogerclarkmelbourne/arduino-esp8266/tree/master/tools/xtensa-lx106-elf (it includes crt1-sim.o, _vectors.o and others libs) but it not help.

I haven't find final answer: "If there a way to use std::map and so on in Sming?"

Thanks in advance for help.


Solution

  • Build it after all. In the end it was simple.

    I should add stdc++ supc++ to LIBS not to LDFLAGS That is:

    LIBS = stdc++ supc++ microc ...
    

    And remain LDFLAGS the same (with -nostdlib)

    LDFLAGS = -nostdlib ...