使用Arduino库与c ++的stringstream链接错误

时间:2016-12-29 11:31:04

标签: arduino linker stringstream esp8266 platformio

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

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

std::stringstream s;

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

void loop()
{

}

应该正确设置所有内容,大多数草图都可以正常运行。 但是当我尝试使用stringstreams时,我会在platformio链接固件时遇到错误。

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,但也许你们中的一些人遇到了类似的问题或者从控制台日志中获得了线索。你能帮我解决这些错误吗?

1 个答案:

答案 0 :(得分:1)

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

Arduino 有自己的libraries,我建议您仔细查看String文档,因为它可能已经提供了项目所需的功能。< / p>

Arduino 有一些C ++库端口,包括 - 从理论上说 - 你可以使用的StringStream端口。

还有ports个C库,但老实说,我不知道这些库的进展/可靠性状态。