本文介绍了用于Arduino IDE的ESP8266(xtensa-lx106-elf-gcc)和std :: map链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有可能使用ESP8266的地图作为Arduino包吗?



这是我的代码:

  #include< map> 

typedef std :: map< int,int>项目;

void setup(){
项目项;
items [2] = 5;
//items.emplace(4,5);
}

void loop(){

}


b $ b

这里是编译/链接erorrs:

  Arduino:1.6.5通用ESP8266模块,串行,80 MHz,40MHz,DIO,115200,512K(64K SPIFFS)

sketch_oct31a.cpp.o:在函数`loop':
C:\Program文件(x86)\Arduino / sketch_oct31a.ino:11:未定义引用'的std :: _ Rb_tree_insert_and_rebalance(布尔,性病:: _ Rb_tree_node_base *,性病:: _ Rb_tree_node_base *,性病:: _ Rb_tree_node_base&安培;)
sketch_oct31a。 cpp.o:在函数`_M_emplace_hint_unique< const std :: piecewise_construct_t& std :: tuple< int&>,std :: tuple< >':
c:\users\user\appdata\roaming\arduino15\packages\esp8266\tools\xtensa-lx106- elf-gcc\1.20.0-26- gb404fb9-2\xtensa-lx106- elf\include\c ++ \4.8.2\bits / stl_tree.h:1673:未定义的引用`的std :: _ Rb_tree_insert_and_rebalance(布尔,性病:: _ Rb_tree_node_base *,标准: :_Rb_tree_node_base *,性病:: _ Rb_tree_node_base&安培;)
sketch_oct31a.cpp.o:在函数'的std :: _ Rb_tree< INT,性病::对< INT常量,INT>中的std :: _ Select1st<的std :: pair< int const,int> >,std :: less< int>,std :: allocator< std :: pair< int const,int& > > :: _ M_erase(std :: _ Rb_tree_node< std :: pair< int const,int>> *)':
c:\users\user\appdata\roaming\arduino15\packages \esp8266\tools\xtensa-lx106- elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106- elf\include\c ++ \4.8.2\bits / stl_tree。 H:1130:未定义的引用`的std :: _ Rb_tree_decrement(的std :: _ Rb_tree_node_base *)'
sketch_oct31a.cpp.o:在函数'的std :: _ Rb_tree_iterator<的std ::对< INT常量,诠释> > :: operator - ()':
c:\users\user\appdata\roaming\arduino15\packages\esp8266\tools\xtensa-lx106- elf-gcc\\ \\1.20.0-26-gb404fb9-2\xtensa-lx106- elf\include\c ++ \4.8.2\bits / stl_tree.h:204:未定义引用`std :: _ Rb_tree_decrement(std :: _Rb_tree_node_base *)'
sketch_oct31a.cpp.o:(.text._ZNSt8_Rb_treeIiSt4pairIKiiESt10_Select1stIS2_ESt4lessIiESaIS2_EE29_M_get _insert_hint_unique_posESt23_Rb_tree_const_iteratorIS2_ERS1 _ [_ ZNSt8_Rb_treeIiSt4 pairIKiiESt10_Select1stIS2_ESt4lessIiESaIS2_EE29_M_get_insert_hint_unique_posESt 23_Rb_tree_const_iteratorIS2_ERS1 _] +为0x0):未定义引用'的std :: _ Rb_tree_increment(的std :: _ Rb_tree_node_base *)'
sketch_oct31a .cpp.o:在函数`std :: _ Rb_tree C:\users\user\appdata\roaming\arduino15 \packages\esp8266\tools\xtensa-lx106- elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c ++ \4.8.2\bits /stl_tree.h:1431:未定义引用'的std :: _ Rb_tree_decrement(的std :: _ Rb_tree_node_base *)'
C:\users\user\appdata\roaming\arduino15\packages\esp8266\\ \\ tools \xtensa-lx106-elf-gcc \1.20.0-26-gb404fb9-2 \xtensa-lx106-elf\include\c ++ \4.8.2\bits / stl_tree.h:1448:未定义的引用`std :: _ Rb_tree_increment(std :: _ Rb_tree_node_base *)'
collect2.exe:错误:ld返回1退出状态
编译错误。

我从这里购买了这个软件包:



BTW任何其他ESP8266编译的文件可以。 p>

提前感谢

解决方案

标准ESP8266设置不会链接到libstdc ++ ,它提供 map 和其他std命名空间代码。



您需要编辑的Platforms.txt 在ESP8266 Arudino文件夹的根目录(此文件夹的位置取决于用于安装什么,你使用的是什么操作系统) - 并添加 - lstdc ++ 到以下行:

  compiler.c.elf.libs = -lm -lgcc  - lhal -lphy -lnet80211 -llwip -lwpa -lmain -lpp -lsmartconfig -lwps -lcrypto -laxtls 

Arduino IDE 仅在启动时读取此文件一次,因此,请确保在编译之前重新启动IDE。


Is it possible at all to use map with ESP8266 for Arduino package?

Here is my code:

#include <map>

typedef std::map<int, int> Items;

void setup() {
  Items items;
  items[2]=5;
  //items.emplace(4,5);
}

void loop() {

}

Here is compilation/linking erorrs:

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

sketch_oct31a.cpp.o: In function `loop':
C:\Program Files (x86)\Arduino/sketch_oct31a.ino:11: 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&)'
sketch_oct31a.cpp.o: In function `_M_emplace_hint_unique<const     std::piecewise_construct_t&, std::tuple<int&&>, std::tuple<> >':
c:\users\user\appdata\roaming\arduino15\packages\esp8266\tools\xtensa-lx106-    elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-    elf\include\c++\4.8.2\bits/stl_tree.h:1673: 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&)'
sketch_oct31a.cpp.o: In function `std::_Rb_tree<int, std::pair<int const,     int>, std::_Select1st<std::pair<int const, int> >, std::less<int>,     std::allocator<std::pair<int const, int> >     >::_M_erase(std::_Rb_tree_node<std::pair<int const, int> >*)':
c:\users\user\appdata\roaming\arduino15\packages\esp8266\tools\xtensa-lx106-    elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-    elf\include\c++\4.8.2\bits/stl_tree.h:1130: undefined reference to     `std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
sketch_oct31a.cpp.o: In function `std::_Rb_tree_iterator<std::pair<int     const, int> >::operator--()':
c:\users\user\appdata\roaming\arduino15\packages\esp8266\tools\xtensa-lx106-    elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-    elf\include\c++\4.8.2\bits/stl_tree.h:204: undefined reference to     `std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
sketch_oct31a.cpp.o:    (.text._ZNSt8_Rb_treeIiSt4pairIKiiESt10_Select1stIS2_ESt4lessIiESaIS2_EE29_M_get    _insert_hint_unique_posESt23_Rb_tree_const_iteratorIS2_ERS1_[_ZNSt8_Rb_treeIiSt4    pairIKiiESt10_Select1stIS2_ESt4lessIiESaIS2_EE29_M_get_insert_hint_unique_posESt    23_Rb_tree_const_iteratorIS2_ERS1_]+0x0): undefined reference to `std::_Rb_tree_increment(std::_Rb_tree_node_base*)'
sketch_oct31a.cpp.o: In function `std::_Rb_tree<int, std::pair<int const,     int>, std::_Select1st<std::pair<int const, int> >, std::less<int>,     std::allocator<std::pair<int const, int> >     >::_M_get_insert_hint_unique_pos(std::_Rb_tree_const_iterator<std::pair<int     const, int> >, int const&)':
c:\users\user\appdata\roaming\arduino15\packages\esp8266\tools\xtensa-lx106-    elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits/stl_tree.h:1431: undefined reference to `std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
c:\users\user\appdata\roaming\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits/stl_tree.h:1448: undefined reference to `std::_Rb_tree_increment(std::_Rb_tree_node_base*)'
collect2.exe: error: ld returned 1 exit status
Error compiling.

I took that package from here: https://github.com/esp8266/Arduino

BTW any other stuff for ESP8266 compiles OK.

Thanks in advance

解决方案

The standard ESP8266 setup does not link against libstdc++, which provides map and other std namespace code.

You'll need to edit platforms.txt in the root of the ESP8266 Arudino folder (The location of this folder depends on what was used to install it, and what OS you are using) - and add -lstdc++ to the following line:

compiler.c.elf.libs=-lm -lgcc -lhal -lphy -lnet80211 -llwip -lwpa -lmain -lpp -lsmartconfig -lwps -lcrypto -laxtls

Arduino IDE only reads this file once at start, so, make sure to restart the IDE before compiling.

这篇关于用于Arduino IDE的ESP8266(xtensa-lx106-elf-gcc)和std :: map链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 19:14