【问题标题】:Platformio Linker Error When Including <functional>包含 <functional> 时的 Platformio 链接器错误
【发布时间】:2019-04-21 15:47:31
【问题描述】:

我在 Windows 10 上使用 PlatformIO(带有 VS Code 扩展),并且正在为 Teensy 3.5 板进行编译。

我已将我的一个项目中的链接器错误减少为以下代码:

#include <Arduino.h>
#include <functional>

void setup()
{
   // Serial.println();
  std::function<void()> func;
  func();
}

void loop() {}

当我尝试编译和链接它时,它编译得很好,但无法链接。如果我取消注释 Serial.println(),那么它会链接并编译。

我在 platformio.ini 文件中使用以下设置:

[env:teensy35]
platform = teensy
board = teensy35
framework = arduino

链接失败时给出的错误是:

c:/users/zackh/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../ arm-none-eabi/lib/armv7e-m/fpu\libc.a(lib_a-writer.o):在函数_write_r': writer.c:(.text._write_r+0x12): undefined reference to_write' collect2.exe:错误:ld 返回 1 个退出状态

知道这里发生了什么吗?

【问题讨论】:

    标签: c++ arduino teensy platformio


    【解决方案1】:

    我找到的解决方案是在 platformio.ini 项目中包含以下行。

    build_flags = -llibc -lc
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-08
      • 2021-01-26
      • 1970-01-01
      • 1970-01-01
      • 2012-07-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多