用于Arduino IDE的ESP8266(extenssa-lx106-elf-gcc)和std::映射链接错误
ESP8266 for Arduino IDE (xtensa-lx106-elf-gcc) and std::map linking error
是否可以将map与ESP8266一起用于Arduino包?
这是我的代码:
#include <map>
typedef std::map<int, int> Items;
void setup() {
Items items;
items[2]=5;
//items.emplace(4,5);
}
void loop() {
}
这里是编译/链接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:usersuserappdataroamingarduino15packagesesp8266toolsxtensa-lx106- elf-gcc1.20.0-26-gb404fb9-2xtensa-lx106- elfincludec++4.8.2bits/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:usersuserappdataroamingarduino15packagesesp8266toolsxtensa-lx106- elf-gcc1.20.0-26-gb404fb9-2xtensa-lx106- elfincludec++4.8.2bits/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:usersuserappdataroamingarduino15packagesesp8266toolsxtensa-lx106- elf-gcc1.20.0-26-gb404fb9-2xtensa-lx106- elfincludec++4.8.2bits/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:usersuserappdataroamingarduino15packagesesp8266toolsxtensa-lx106- elf-gcc1.20.0-26-gb404fb9-2xtensa-lx106-elfincludec++4.8.2bits/stl_tree.h:1431: undefined reference to `std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
c:usersuserappdataroamingarduino15packagesesp8266toolsxtensa-lx106-elf-gcc1.20.0-26-gb404fb9-2xtensa-lx106-elfincludec++4.8.2bits/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.
我从这里拿走了那个包裹:https://github.com/esp8266/Arduino
顺便说一句,ESP8266的任何其他东西都可以编译。
提前感谢
标准的ESP8266设置不与libstdc++链接,后者提供map
和其他std命名空间代码。
您需要在ESP8266 Arudino文件夹的根目录中编辑platforms.txt
(此文件夹的位置取决于用于安装它的内容和您使用的操作系统),并将-lstdc++
添加到以下行:
compiler.c.elf.libs=-lm -lgcc -lhal -lphy -lnet80211 -llwip -lwpa -lmain -lpp -lsmartconfig -lwps -lcrypto -laxtls
Arduino IDE在启动时只读取此文件一次,因此,请确保在编译之前重新启动IDE。
如果它仍然不起作用(因为libstdc++对于您的工具链来说是不完整的),请在https://github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/src/c++98/tree.cc并将其重命名为tree.cpp。这对我很有效。
相关文章:
- C++匿名结构作为std::映射值
- 如何从存储在std::映射中的std::集中删除元素
- 从嵌套在std::映射中的std::列表中删除元素的最佳方式
- 将唯一指针插入std::映射
- 重载std::映射不同的密钥类型
- std::映射,只有move构造函数可用
- std::映射服装比较函数和函数/lambda错误
- std::映射导致插入时出现C2664错误
- 将从std::映射中获取的std::pair引用传递给接受std::对引用的函数
- std::映射键作为模板化结构与枚举成员
- std ::映射以构造为钥匙
- 在锁定下清除STD ::映射,而移动到临时对象
- 计算向量的std ::映射为键的值,并将双倍作为值
- 写入/读取 std::映射到二进制文件需要运算符
- 我如何正确地为std ::映射分配内存
- 如何打印包含整数和整数集的std::映射
- 在字符串的std::映射中找到编译错误,long
- 将std ::映射复制到std ::对向量
- 使用std ::映射的键的部分匹配
- 遍历std ::映射,效果少于迭代器之间的比较