Arduino编译错误解决办法:fork/exec:…\arm-none-eabi-g++.exe: The filename or extension is too long

2023-11-17

编译错误解决办法:fork/exec:…\arm-none-eabi-g++.exe: The filename or extension is too long

解决方案来自Edge Impulse

当使用Arduino编译STM或Arduino文件时,当要编译的目标文件列表超过命令行中的Windows最大字符数(32k)时,通常会引发此错误。

如果使用的2.0版本以下IDE版本,可参考以下方法:

如果是Arduino则使用前两种方法即可,Adafruit、esp32、STM32参照后面的方法

1.在Arduino mbed目录下,即:C:\Users\(自己的用户名)\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.1.4\ (版本号可能不同)
创建platform.local.txt 并粘贴以下代码 :

## Customized platform.local.txt to compile for mbed targets under Windows
## This recipe works around the Windows limit of 32k characters in a cmd line by calling .o files from a text file during linking
## Install: put file under your mbed sub-directory - ie: C:\Users\MYUSER\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.1.4
## You can also find the local arduino folder in the IDE under File -> Preferences -> see preferences.txt location in the bottom part of the window

## hooks

# create a txt file with all object file paths from libraries and sketch folders (core\variant.cpp.o needed too for linking)
recipe.hooks.linking.prelink.1.pattern=cmd /c dir /b /s {build.path}\sketch\*.o > {build.path}\obj_files_tmp.txt
recipe.hooks.linking.prelink.2.pattern=cmd /c "dir /b /s {build.path}\libraries\*.o >> {build.path}\obj_files_tmp.txt 2>nul & exit 0"
recipe.hooks.linking.prelink.3.pattern=cmd /c echo "{build.path}\core\variant.cpp.o" >> {build.path}\obj_files_tmp.txt

# replace \ by \\ in file paths (otherwise escaped by linker) and save in new txt file
recipe.hooks.linking.prelink.4.pattern=cmd /v /c "@echo off && for /f %a in ({build.path}\obj_files_tmp.txt) do (set line=%a && set line=!line:\=\\! && echo !line! >> {build.path}\obj_files.txt)"

# delete txt file after linking
recipe.hooks.linking.postlink.1.pattern=cmd /c del {build.path}\obj_files.txt


## modify compile patterns (@{build.path}\obj_files.txt)

recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}"  "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "@{compiler.mbed.ldflags}" "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" @{build.path}\obj_files.txt -Wl,--whole-archive "{build.path}/{archive_file}" {compiler.mbed} -Wl,--no-whole-archive -Wl,--start-group {compiler.mbed.extra_ldflags} {compiler.libraries.ldflags} -Wl,--end-group

如图所示:在这里插入图片描述

2.在Arduino samd目录下,即:C:\Users\(自己的用户名)\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.1.4
创建platform.local.txt 并粘贴以下代码 :

## Customized platform.local.txt to compile for SAMD21 targets under Windows
## This recipe works around the Windows limit of 32k characters in a cmd line by calling .o files from a text file during linking
## Install: put file under your mbed sub-directory - ie: C:\Users\MYUSER\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.9
## You can also find the local arduino folder in the IDE under File -> Preferences -> see preferences.txt location in the bottom part of the window

## hooks

# create a txt file with all object file paths from libraries and sketch folders (core\variant.cpp.o needed too for linking)
recipe.hooks.linking.prelink.1.pattern=cmd /c dir /b /s {build.path}\sketch\*.o > {build.path}\obj_files_tmp.txt
recipe.hooks.linking.prelink.2.pattern=cmd /c "dir /b /s {build.path}\libraries\*.o >> {build.path}\obj_files_tmp.txt 2>nul & exit 0"
recipe.hooks.linking.prelink.3.pattern=cmd /c echo "{build.path}\core\variant.cpp.o" >> {build.path}\obj_files_tmp.txt

# replace \ by \\ in file paths (otherwise escaped by linker) and save in new txt file
recipe.hooks.linking.prelink.4.pattern=cmd /v /c "@echo off && for /f %a in ({build.path}\obj_files_tmp.txt) do (set line=%a && set line=!line:\=\\! && echo !line! >> {build.path}\obj_files.txt)"

# delete txt file after linking
recipe.hooks.linking.postlink.1.pattern=cmd /c del {build.path}\obj_files.txt


## modify compile patterns (@{build.path}\obj_files.txt)
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}"  "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" @{build.path}\obj_files.txt {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} -lm "{build.path}/{archive_file}" -Wl,--end-group

3.如果是Adafruit,则
在Arduino Adafruit samd目录下,即:C:\Users\(自己的用户名)\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.6.3
创建platform.local.txt 并粘贴以下代码 :

## Customized platform.local.txt to compile for Adafruit SAMD51 targets under Windows
## This recipe works around the Windows limit of 32k characters in a cmd line by calling .o files from a text file during linking
## Install: put file under your mbed sub-directory - ie: C:\Users\MYUSER\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.9
## You can also find the local arduino folder in the IDE under File -> Preferences -> see preferences.txt location in the bottom part of the window

## hooks

# create a txt file with all object file paths from libraries and sketch folders (core\variant.cpp.o needed too for linking)
recipe.hooks.linking.prelink.1.pattern=cmd /c dir /b /s {build.path}\sketch\*.o > {build.path}\obj_files_tmp.txt
recipe.hooks.linking.prelink.2.pattern=cmd /c "dir /b /s {build.path}\libraries\*.o >> {build.path}\obj_files_tmp.txt 2>nul & exit 0"
recipe.hooks.linking.prelink.3.pattern=cmd /c echo "{build.path}\core\variant.cpp.o" >> {build.path}\obj_files_tmp.txt

# replace \ by \\ in file paths (otherwise escaped by linker) and save in new txt file
recipe.hooks.linking.prelink.4.pattern=cmd /v /c "@echo off && for /f %a in ({build.path}\obj_files_tmp.txt) do (set line=%a && set line=!line:\=\\! && echo !line! >> {build.path}\obj_files.txt)"

# delete txt file after linking
recipe.hooks.linking.postlink.1.pattern=cmd /c del {build.path}\obj_files.txt


## modify compile patterns (@{build.path}\obj_files.txt)
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}"  "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" @{build.path}\obj_files.txt {compiler.libraries.ldflags} -Wl,--start-group {compiler.arm.cmsis.ldflags} "-L{build.variant.path}" -lm "{build.path}/{archive_file}" -Wl,--end-group

4.如果是ESP32,则在Arduino ESP32目录下,即:C:\Users\(自己的用户名)\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4
创建platform.local.txt 并粘贴以下代码 :


## Customized platform.local.txt to compile for ESP32 targets under Windows
## This recipe works around the Windows limit of 32k characters in a cmd line, creating an archive with sketch and libraries object files before linking
## Install: put file under your esp32 sub-directory - ie:C:\Users\MYUSER\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4
## You can also find the local arduino folder in the IDE under File -> Preferences -> see preferences.txt location in the bottom part of the window

## hooks

# create a txt file with all object file paths from libraries and sketch folders
recipe.hooks.linking.prelink.1.pattern=cmd /c dir /b /s {build.path}\sketch\*.o > {build.path}\obj_files_tmp.txt
recipe.hooks.linking.prelink.2.pattern=cmd /c "dir /b /s {build.path}\libraries\*.o >> {build.path}\obj_files_tmp.txt 2>nul & exit 0"

# replace \ by \\ in file paths (otherwise escaped by linker) and save in new txt file
recipe.hooks.linking.prelink.3.pattern=cmd /v /c "@echo off && for /f %a in ({build.path}\obj_files_tmp.txt) do (set line=%a && set line=!line:\=\\! && echo !line! >> {build.path}\obj_files.txt)"

# save object files in archive
recipe.hooks.linking.prelink.4.pattern=cmd /v /c "@echo off && for /f %a in ({build.path}\obj_files.txt) do ({compiler.path}{compiler.ar.cmd} {compiler.ar.flags} {compiler.ar.extra_flags} {build.path}\custom_lib.a %a)"

# delete txt file and archive after linking
recipe.hooks.linking.postlink.1.pattern=cmd /c del {build.path}\obj_files.txt
recipe.hooks.linking.postlink.2.pattern=cmd /c del {build.path}\custom_lib.a


## modify compile patterns (use custom_lib.a instead of object_files)
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} -Wl,--start-group "{build.path}\custom_lib.a" "{archive_file_path}" {compiler.c.elf.libs} -Wl,--end-group -Wl,-EL -o "{build.path}/{build.project_name}.elf"

5.如果是STM32,则在Arduino STM32目录下,即:C:\Users\(自己的用户名)\AppData\Local\Arduino15\packages\esp32\hardware\stm32\1.9.0
创建platform.local.txt 并粘贴以下代码 :

## Customized platform.local.txt to compile for STM32 targets under Windows
## This recipe works around the Windows limit of 32k characters in a cmd line by calling .o files from a text file during linking
## Install: put file under your mbed sub-directory - ie: C:\Users\MYUSER\AppData\Local\Arduino15\packages\arduino\hardware\stm32\1.9.0
## You can also find the local arduino folder in the IDE under File -> Preferences -> see preferences.txt location in the bottom part of the window

## hooks

# create a txt file with all object file paths from libraries and sketch folders
recipe.hooks.linking.prelink.1.pattern=cmd /c dir /b /s {build.path}\sketch\*.o > {build.path}\obj_files_tmp.txt
recipe.hooks.linking.prelink.2.pattern=cmd /c "dir /b /s {build.path}\libraries\*.o >> {build.path}\obj_files_tmp.txt 2>nul & exit 0"
recipe.hooks.linking.prelink.3.pattern=cmd /c echo "{build.path}\core\variant.cpp.o" >> {build.path}\obj_files_tmp.txt
recipe.hooks.linking.prelink.4.pattern=cmd /c echo "{build.path}\core\PeripheralPins.c.o" >> {build.path}\obj_files_tmp.txt

# replace \ by \\ in file paths (otherwise escaped by linker) and save in new txt file
recipe.hooks.linking.prelink.5.pattern=cmd /v /c "@echo off && for /f %a in ({build.path}\obj_files_tmp.txt) do (set line=%a && set line=!line:\=\\! && echo !line! >> {build.path}\obj_files.txt)"

# delete txt file after linking
recipe.hooks.linking.postlink.1.pattern=cmd /c del {build.path}\obj_files.txt


## modify compile patterns (@{build.path}\obj_files.txt)
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} "-Wl,--default-script={build.variant.path}/{build.ldscript}" "-Wl,--script={build.system.path}/ldscript.ld" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} {compiler.ldflags} {compiler.arm.cmsis.ldflags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -Wl,--start-group @{build.path}\obj_files.txt {compiler.libraries.ldflags} "{archive_file_path}" -lc -Wl,--end-group -lm -lgcc -lstdc++

进行以上操作后,测试编译成功
在这里插入图片描述

如果您觉得文章对您有帮助,欢迎转发打赏
在这里插入图片描述

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Arduino编译错误解决办法:fork/exec:…\arm-none-eabi-g++.exe: The filename or extension is too long 的相关文章

  • Qt 5 和 OS X Mavericks 问题

    我正在使用 Cmake 在 OS X 10 9 上构建 QT 项目 自 Mavericks 以来 OpenGL 标头的位置似乎发生了变化 文件夹 System Library Frameworks OpenGL framework Head
  • CMake 链接失败

    我正在为 CMake 配置我的项目 并且遇到链接问题 项目文件全部编译成功 然后它说它正在链接并报告未找到的各种符号 这些符号大部分是由我自己的代码提供的 其中一些是由 BerkeleyDB 提供的 它已被正确定位并包含在内 这是我的顶级
  • CMake 错误“找不到要添加属性的目标”

    在我的 CMakeLIsts txt 文件中我这样写 set LIBHELLO SRC hello c set target properties hello static PROPERTIES OUTPUT NAME hello get
  • 单个 CMakeLists.txt 足以满足我的项目需求吗?

    我正在尝试将旧的 CMake 移植到现代 CMake CMake 3 0 2 或更高版本 在旧的设计中 我有多个 CMakelists txt 每个目录都包含一个 CMakeLists txt 文件 我当前项目的目录结构如下所示 VizSi
  • 通过iPhone音频插孔读取数据

    我正在寻找一种方法来读取通过 iPhone 的音频插孔从 Arduino 发送的原始数据 我搜索了很多并发现this https github com sanjibahmad Is Headphone Plugged In tree mas
  • M1 MacBook Pro 和 cmake 的编译错误

    我刚刚拿到了新的 M1 MacBook Pro 正在尝试编译大学工作所需的代码库 以下是我已采取的步骤 我使用 Rosetta 将终端设置为始终打开 安装的自制程序using bin bash c curl fsSL https raw g
  • Qt5 CMake 将所有库包含到可执行文件中

    我正在尝试使用 Qt 5 14 构建一个发布模式下的应用程序 并且 Qt Creator 内部一切正常 但是当我尝试单独运行可执行文件时 我收到如下错误 OS Windows 10 Qt 5 14 Cmake 3 5 我尝试过的 设置 CM
  • 如何安装和使用 YAML-Cpp

    我想学习 YAML 并将其与 C 一起使用 但我一直在尝试设置YAML Cpp 让我解释一下到目前为止我所做的事情 我下载了源代码 版本0 5 1 安装的 Cmake 适用于 Windows 安装了 Boost 库 为 Visual Stu
  • 在cmake中检测项目语言

    我想检测当前的项目语言 例如 如果我有这样的东西 cmake minimum required VERSION 3 0 project foo VERSION 1 0 LANGUAGES CXX 我需要这样的东西 if project la
  • 设置 CMake OBJECT 库的输出目录

    在我的 CMake 文件中 我指定了一个对象库 add library core OBJECT sourcefiles 我在共享库中进一步引用了这组目标文件 add library sharedlib SHARED
  • 来自库的 CMake link_directories

    我正在尝试使用 CMake 和 Xcode 从另一个库链接到一个库 这对任何图书馆来说都是一个问题 但为了让事情更容易传达 让我们使用zlib举个例子 这似乎适用于可执行文件 如下所示 LINK DIRECTORIES LIB DIR zl
  • cmake 找不到 boost 库,因为它查找错误的文件名

    我根据文档在 Windows 8 1 机器上构建了 boost 1 56 库 作为共享库和静态库 他们全部出现在BOOST ROOT stage lib目录 文件名格式如下 boost thread vc120 mt 1 56 dll bo
  • CMake 错误:CMake 无法找到与“MinGW Makefiles”对应的构建程序

    我正在尝试使用 cmake 为 c 构建 Box2D 库 当我运行 cmake gui 时出现错误 CMake Error CMake was unable to find a build program corresponding to
  • 如何设置 CMake 与 clang 交叉编译 Windows 上的 ARM 嵌入式系统?

    我正在尝试生成 Ninja makefile 以使用 Clang 为 ARM Cortex A5 CPU 交叉编译 C 项目 我为 CMake 创建了一个工具链文件 但似乎存在错误或缺少一些我无法找到的东西 当使用下面的工具链文件调用 CM
  • cmake 不会在更改时重建 externalProject

    我有以下 CMakeLists txt cmake minimum required VERSION 3 0 project addProject include ExternalProject set ExternalProjectCMa
  • libSDL、CMake 和 Mac OS X Lion

    我正在尝试在我的Mac上编译cmake项目 但它取决于SDL框架 我安装了这个框架 在 cmake 之后向我报告找不到 libSDL 我自己设置了以下导出变量 按照 cmake 的建议 export SDL INCLUDE DIR Libr
  • cmake:设置多个项目以及它们之间的依赖关系

    我需要帮助为 C 项目编写一个好的 CMakeLists txt 我寻找答案 但我发现了什么 这是我的项目结构 MainProj ProjLib include proj lib h src proj lib cc CMakeLists t
  • target_link_libraries 和 INCLUDE_DIRECTORIES 属性

    在这个片段中 cmake minimum required VERSION 3 0 project hello LANGUAGES C VERSION 0 0 1 add library a INTERFACE target include
  • 在 VS2017 下使用 Conan 和 CMake 项目进行依赖管理

    我正在尝试使用 CMake 与 VS2017 集成为 C 设置一个开发环境 以便在 Linux x64 下进行编译 为了更好地管理依赖关系 我选择使用 Conan 但我对这个软件还很陌生 我想知道让 VS2017 识别项目依赖关系的最佳方法
  • 有关 CMake 错误的问题:没有为目标提供源

    我正在尝试使用 cmake 和 eclipse 将 FreeRtos 添加到我的项目中 但出现错误 我运行的是 debian 10 我的 cmake 版本是 3 13 4 cmake 的文件可以在以下位置找到这个 git 仓库 https

随机推荐

  • 玩转X-CTR100 l STM32F4 l U-Blox NEO-6M GPS卫星定位-nmealib解码库移植解码

    我造轮子 你造车 创客一起造起来 塔克创新资讯 塔克社区 www xtark cn 塔克博客 www cnblogs com xtark 本文介绍X CTR100控制器 扩展GPS卫星定位模块 型号为GY GPS6MV2 使用U BLOX
  • 数据库连接自动断开:CJCommunicationsException

    报错信息 com mysql cj exceptions CJCommunicationsException The last packet successfully received from the server was 99 117
  • JavaSE基础知识(个人总结)

    声明 1 本文为我的个人复习总结 并非那种从零基础开始普及知识 内容详细全面 言辞官方的文章 2 由于是个人总结 所以用最精简的话语来写文章 3 若有错误不当之处 请指出 基础 杂记 JRE JVM 常用类库 JDK JRE 诸多工具 如j
  • vue 循环遍历 搜寻资料

    写vue 循环遍历的 大全例子解释 转载连接 https www cnblogs com xulei1992 p 6015416 html https www jqhtml com 49765 html https blog csdn ne
  • mysql truncate语句_MySQL DELETE语句和TRUNCATE TABLE语句的区别

    在MySQL数据库中 DELETE语句和TRUNCATE TABLE语句都可以用来删除数据 但是这两种语句还是有着其区别的 下文就为您介绍这二者的差别所在 MySQL DELETE语句和TRUNCATE TABLE语句功能相似 但是二者究竟
  • Unity 游戏入门 九、 精灵动画 Sprite Animation

    1 Animator 为了在游戏对象上有动画 需要添加一个组件Animator 在工程窗口中 双击Robot 预制体 如图所示 添加Animator组件 2 Creating a New Controller 在工程窗口Animator文件
  • 分组排序取前几条之子查询和用户变量的使用

    关于一次面试的sql题 题目 在一张订单表中有三个字段 order id sale num type 类型有 衣服 鞋子 皮包 现在希望取出每种类型销量前三的记录 我在面试时候还想 啥 啥玩意 要我写单表的查询 看不起我 这不就是group
  • [QT编程系列-31]:多线程机制 - Qthread工作原理

    目录 一 Qthread工作原理 二 QThread的start 方法 三 QT 线程的生命周期 四 事件循环机制 五 QThread自带信号 六 如何在run函数中多次执行 七 QThread什么时候发送finished信号 八 为什么不
  • VS2019运行报错:引发了未经处理的异常:读取访问权限冲突。_Pnext 是 0xE。

    我们在运行VS2019代码时 报错如下信息 反复检查了代码 发现代码是没有问题的 我的代码如下 include
  • 用Java写一个五子棋小游戏

    棋盘是15 15 可以自己规定 游戏规则 1 对局双方各执一色棋子 2 空棋盘开局 3 黑先 白后 交替下子 每次只能下一子 4 棋子下在棋盘的空白点上 棋子下定后 不得向其它点移动 不得从棋盘上拿掉或拿起另落别处 5 黑方的第一枚棋子可下
  • vue form表单最简写法

    vue form表单最简单写法 div div
  • 均值不等式链的几何证明

    均值不等式链的几何证明 这是我们高中时所见到的不等式链的关系 接下来将用几何图形的方法进行证明 首先 做圆 A 直径 BC 在圆上异于 BC 取一点 D 连接 DA DB DC 并做 DE 垂直与 BC 交 BC 与点 E 设 CE a B
  • springbooot_如何正确使用mybatis连接mysql

    MyBatis不是spring旗下的框架 所以在springboot中使用还是需要配置一下 不过配置非常简单 1 第一步 创建springboot项目 需要联网 2 第二步 就是给项目起名的一些操作 完成后点击next 3 第三步 别忘了在
  • CK-GW208-EC与汇川PLC配置走EtherCAT通讯指南

    CK GW208 EC这款产品是晨控智能一款工业级 IO LINK 主站网关 支持 EtherCat 工业协议 可通过以太网接口 对 IO LINK 从站设备进行控制 CK GW208 EC 是一款支持标准工业 Ethercat协议的 IO
  • Java网络多线程——UDP编程

    UDP编程通信 基本介绍 类DatagramSocket和DatagramPacket 数据包 数据报 实现了基于UDP协议网络程序 UDP数据报通过数据报套接字DatagramSocket发送和接收 系统不保证UDP数据报一定能安全送到目
  • Mac OS Wireshark 权限不足

    Mac OS Wireshark 权限不足 切换为root用户 sudo su root 切换到 dev目录 cd dev 查看bpf文件的权限 Wireshark监控数据包需要有bpf的读权限 ls l grep bpf bpf文件的权限
  • python实践第5章-函数和lambda表达式

    1 定义一个函数 该函数可接收一个 list 作为参数 该函数使用直接选择排序对 list排序 def ssort list lens len list for i in range lens min i for j in range i
  • 磐云PY-B8 网页注入

    文章目录 1 使用渗透机场景windows7中火狐浏览器访问服务器场景中的get php 根据页面回显获取Flag并提交 2 使用渗透机场景windows7中火狐浏览器访问服务器场景中的post php 根据页面回显获取Flag并提交 3
  • 无线网破解 跑字典 EWSA使用教程

    无线网破解 跑字典 EWSA使用教程 导入握手包 配置攻击字典 步骤阅读 配置EWSA 1 选项 字典DIY 字典设置 密码变化选项 把勾选都去掉 2 选项 字典DIY 字典设置 导入我们自己的字典 生日字典和8位纯数字字典 点击开始测试
  • Arduino编译错误解决办法:fork/exec:…\arm-none-eabi-g++.exe: The filename or extension is too long

    编译错误解决办法 fork exec arm none eabi g exe The filename or extension is too long 解决方案来自Edge Impulse 当使用Arduino编译STM或Arduino文