使用Arduino库和C ++的stringstream链接错误 [英] Linking error using Arduino library with c++'s stringstream

查看:111
本文介绍了使用Arduino库和C ++的stringstream链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 esp8266 platformio 来编写一个简单的草图.

I am using an esp8266 together with platformio to write a simple sketch.

#include <sstream>
#include <Arduino.h>

std::stringstream s;

void setup()
{
    Serial.begin(9600);
    Serial.println("Test");
}

void loop()
{

}

应该正确设置所有内容,并且大多数草图都可以正常工作. 但是,一旦我尝试使用字符串流,当platformio链接固件时,我就会出错.

Everything should be setup correctly and most sketches worked without issues. But as soon as I try to use stringstreams I get errors when platformio is linking the firmware.

platformio run
[12/29/16 12:11:32] Processing esp12e (platform: espressif8266, board: nodemcu, framework: arduino)

Verbose mode can be enabled via `-v, --verbose` option
Collected 23 compatible libraries
Looking for dependencies...
Project does not have dependencies
Linking .pioenvs\esp12e\firmware.elf

c:/users/simon/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pioenvs\esp12e\firmware.elf section `.text' will not fit in region `iram1_0_seg'
C:\users\simon\.platformio\packages\framework-arduinoespressif8266\tools\sdk\lib\libstdc++.a(locale-inst.o):(.literal._ZSt16__convert_from_vRKPiPciPKcz[_ZSt16__convert_from_vRKPiPciPKcz]+0x4): undefined reference to `setlo
cale'
C:\users\simon\.platformio\packages\framework-arduinoespressif8266\tools\sdk\lib\libstdc++.a(locale-inst.o):(.literal._ZSt16__convert_from_vRKPiPciPKcz[_ZSt16__convert_from_vRKPiPciPKcz]+0xc): undefined reference to `vspri
ntf'
C:\users\simon\.platformio\packages\framework-arduinoespressif8266\tools\sdk\lib\libstdc++.a(locale-inst.o):(.literal._ZSt9use_facetISt5ctypeIcEERKT_RKSt6locale[_ZSt9use_facetISt5ctypeIcEERKT_RKSt6locale]+0x4): undefined r
eference to `std::__throw_bad_cast()'
C:\users\simon\.platformio\packages\framework-arduinoespressif8266\tools\sdk\lib\libstdc++.a(locale-inst.o):(.literal._ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE15_M_insert_floatIdEES3_S3_RSt8ios_baseccT_
[_ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE15_M_insert_floatIdEES3_S3_RSt8ios_baseccT_]+0x0): undefined reference to `memchr'
C:\users\simon\.platformio\packages\framework-arduinoespressif8266\tools\sdk\lib\libstdc++.a(locale-inst.o): In function `std::__convert_from_v(int* const&, char*, int, char const*, ...)':
/Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/bits/locale_classes.tcc:114: undefined reference to `setlocale'
/Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/bits/locale_classes.tcc:114: undefined reference to `setlocale'
/Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/bits/locale_classes.tcc:114: undefined reference to `vsprintf'
/Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/bits/locale_classes.tcc:114: undefined reference to `setlocale'
C:\users\simon\.platformio\packages\framework-arduinoespressif8266\tools\sdk\lib\libstdc++.a(locale-inst.o): In function `std::ctype<char> const& std::use_facet<std::ctype<char> >(std::locale const&)':
/Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/bits/locale_classes.tcc:114: undefined reference to `std::__throw_bad_cast()'
C:\users\simon\.platformio\packages\framework-arduinoespressif8266\tools\sdk\lib\libstdc++.a(locale-inst.o): In function `std::numpunct<char> const& std::use_facet<std::numpunct<char> >(std::locale const&)':
/Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/bits/locale_classes.tcc:114: undefined reference to `std::__throw_bad_cast()'
C:\users\simon\.platformio\packages\framework-arduinoespressif8266\tools\sdk\lib\libstdc++.a(locale-inst.o): In function `std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > > const& std::use_facet<s
td::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > > >(std::locale const&)':
/Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/bits/locale_classes.tcc:114: undefined reference to `std::__throw_bad_cast()'
C:\users\simon\.platformio\packages\framework-arduinoespressif8266\tools\sdk\lib\libstdc++.a(locale-inst.o): In function `std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > > const& std::use_facet<s
td::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > > >(std::locale const&)':
/Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/bits/locale_classes.tcc:114: undefined reference to `std::__throw_bad_cast()'
C:\users\simon\.platformio\packages\framework-arduinoespressif8266\tools\sdk\lib\libstdc++.a(locale-inst.o): In function `std::moneypunct<char, true> const& std::use_facet<std::moneypunct<char, true> >(std::locale const&)'
:
/Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/bits/locale_classes.tcc:114: undefined reference to `std::__throw_bad_cast()'
C:\users\simon\.platformio\packages\framework-arduinoespressif8266\tools\sdk\lib\libstdc++.a(locale-inst.o):/Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libst
dc++-v3/include/bits/locale_classes.tcc:114: more undefined references to `std::__throw_bad_cast()' follow
C:\users\simon\.platformio\packages\framework-arduinoespressif8266\tools\sdk\lib\libstdc++.a(locale-inst.o): In function `std::ostreambuf_iterator<char, std::char_traits<char> > std::num_put<char, std::ostreambuf_iterator<
char, std::char_traits<char> > >::_M_insert_float<double>(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, char, double) const':
/Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/bits/locale_classes.tcc:114: undefined reference to `memchr'
C:\users\simon\.platformio\packages\framework-arduinoespressif8266\tools\sdk\lib\libstdc++.a(locale-inst.o): In function `std::ostreambuf_iterator<char, std::char_traits<char> > std::num_put

A lot more similar errors

----------

collect2.exe: error: ld returned 1 exit status
*** [.pioenvs\esp12e\firmware.elf] Error 1
 [ERROR] Took 8.38 seconds

对于 platformio 和esp编程我还是很陌生,但是也许你们中的一些人遇到了类似的问题或从控制台日志中获得了线索.您能帮我解决这些错误吗?

I am quite new to platformio and programming the esp but maybe some of you encountered a similar issue or got clues from the console log. Could you help me fix these errors?

推荐答案

据我所知,您不能轻松在您的项目或大多数其他C ++库中包含sstream.

As far as I know, you cannot easily include sstream in your project nor most other C++ libraries.

Arduino 有他自己的您可以仔细阅读 String 文档,因为它可能已经提供了您所需要的功能项目中需要.

Arduino has his own libraries, I advice you to take a closer look to the String documentation as it might already provide the functionality you need in your project.

有一些用于 Arduino 的C ++库端口,包括 StringStream 移植-从理论上讲-您可以使用.

There are some C++ library ports out there for Arduino, including a StringStream port that --theoretically speaking-- you could use.

还有

There are also ports of C libraries, but I honestly don't know what is the state of advancement/reliability of these libraries.

这篇关于使用Arduino库和C ++的stringstream链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆