Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Unable to compile with STL - map.emplace not found (Read 1634 times)
Fetter Doubt
Newbies
*
Offline


Posts: 2
Joined: Feb 23rd, 2020
Unable to compile with STL - map.emplace not found
Feb 23rd, 2020 at 7:50pm
Print Post  
VS 2019 Pro, latest Visual Micro IDE extension

Code (C++)
Select All
#include <map>
#include <string>

std::map<int, std::string> myMap;

// the setup function runs once when you press reset or power the board
void setup() {
    while (!Serial) {}

    myMap.emplace(1, "Hello");
    myMap.emplace(2, "STL");

    Serial.println(myMap[1].c_str()); // Hello
    Serial.println(myMap[2].c_str()); // STL
}

// the loop function runs over and over again until power down or reset
void loop() {
 
} 



Code
Select All
Compiling debug version of 'Sketch1' for 'Teensy 3.2 / 3.1'

Sketch1.cpp.o: In function std::_Rb_tree_iterator<std::pair<int const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::operator--()

Error linking for board Teensy 3.2 / 3.1
stl_tree.h:220: undefined reference to std  _Rb_tree_decrement(std  _Rb_tree_node_base*)
Debug build failed for project 'Sketch1'

Sketch1.cpp.o: In function std::_Rb_tree<int, std::pair<int const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::_Select1st<std::pair<int const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::less<int>, std::allocator<std::pair<int const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::_M_insert_node(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node<std::pair<int const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >*)
stl_tree.h:2105: 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&)

Sketch1.cpp.o: In function void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag)
basic_string.tcc:219: undefined reference to std  __cxx11  basic_string<char, std  char_traits<char>, std  allocator<char> >  _M_create(unsigned int&, unsigned int)
basic_string.tcc:212: undefined reference to std  __throw_logic_error(char const*)

Sketch1.cpp.o: In function std::_Rb_tree_iterator<std::pair<int const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::operator--()
stl_tree.h:220: undefined reference to std  _Rb_tree_decrement(std  _Rb_tree_node_base*)

Sketch1.cpp.o: In function std::_Rb_tree_iterator<std::pair<int const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::operator++()
stl_tree.h:205: undefined reference to std  _Rb_tree_increment(std  _Rb_tree_node_base*)

collect2.exe*: error: ld returned 1 exit status
 

« Last Edit: Feb 23rd, 2020 at 8:00pm by Fetter Doubt »  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2697
Joined: Feb 13th, 2019
Re: Unable to compile with STL - map.emplace not found
Reply #1 - Feb 24th, 2020 at 12:12pm
Print Post  
The C++ Standard Template Libraries aren't automatically available in Arduino sketches, and have to be added using Libraries, and their functionality may be limited compared to the full STL.

Some Examples of external Libraries available are below:
https://www.arduinolibraries.info/libraries/arduino-stl
https://github.com/maniacbug/StandardCplusplus
  
Back to top
IP Logged
 
Fetter Doubt
Newbies
*
Offline


Posts: 2
Joined: Feb 23rd, 2020
Re: Unable to compile with STL - map.emplace not found
Reply #2 - Feb 26th, 2020 at 9:25am
Print Post  
First of all, my bad: I forgot to mention I'm working with Teensy 3.1/3/2 and teensyduino which does support the STL.
Second of all, it looks like a bug in teensyduino: https://forum.pjrc.com/threads/59716-ArduinioSTL-fails-to-compile
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint