-->
Page 1 of 1

Weird linker error

PostPosted: Wed Apr 27, 2016 10:43 am
by frischevollmilch
Hello, sorry for the unspecific title but I couldn't think of a better title.

I reduced my code to this simple example:

Code: Select all#include <list>


class C
{
  public:
  struct s
  {
    String a;
    String b;
  };
  std::list<s> l;
  void add(String a, String b) { s mys = {a, b}; l.push_back(mys); }
};

void setup() {
  C myC;
  myC.add("", "");
}

void loop() {}


When compiling it for the ESP8266 I get the following error:

Code: Select all[...]sketch\sketch_apr25a.ino.cpp.o:(.text.setup+0x4): undefined reference to `std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)'

[...]sketch\sketch_apr25a.ino.cpp.o: In function `setup':

[...]sketch_apr25a.ino:19: undefined reference to `std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)'

collect2.exe: error: ld returned 1 exit status


I tried compiling it in regular C++ (without the Arduino IDE) and it worked fine so I really don't understand what's wrong with my code. Does anybody know what's going on here? (Yes, I tried understanding the error message but couldn't figure it out myself.)

Thanks for reading!