编译错误解决办法: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++

进行以上操作后,测试编译成功

如果您觉得文章对您有帮助,欢迎转发打赏

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

  1. mpalyer 编译错误解决办法

    错误(1) ./codec-cfg ./etc/codecs.conf > codecs.conf.h ./codec-cfg: 1: Syntax error: word unexpected ...

  2. 源代码编码问题带来的gcc编译错误解决办法

    有时候避免不了从网上拷贝代码,直接编译,gcc可能报很多奇怪的错误. 下面是一个cpp文件,用UTF-8编码打开看起来正常,事实上用gedit打开也是正常的. 然而,编译会报错:error: #inc ...

  3. oracle重新编译视图,Oracle视图编译错误解决办法

    因为新搭的环境,数据库是从另一个现成的环境导过来的,直接后台用exp和imp命令操作.但是新环境的Oracle数据库有问题,一些视图创建不了,导致用到这些视图的视图和存储过程也编译不了.后来手工重新编 ...

  4. PHP编译安装时常见错误解决办法,php编译常见错误

    PHP编译安装时常见错误解决办法,php编译常见错误 1.configure: error: xslt-config not found. Please reinstall the libxslt & ...

  5. linux libvpx编译安装,linux编译安装时常见错误解决办法

    **configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution** 复 ...

  6. linux编译安装的报错,linux编译安装时常见错误解决办法

    This article is post on https://coderwall.com/p/ggmpfa 原文链接:http://www.bkjia.com/PHPjc/1008013.html ...

  7. 老是说我编译版本不够_编译etcd出现的cannot load bufio的错误解决办法

    编译etcd出现的cannot load bufio的错误解决办法 今天在安装编译etcd的时候,出现以下错误: go: finding github.com/golang/groupcache v0 ...

  8. Android编译出现com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536错误解决办法

    踩过的坑, 以下操作,必须在app module中进行. ========================================== ** Android编译出现com.android.de ...

  9. 在查找预编译头时遇到意外的文件结尾。是否忘记了向源中添加“#include stdafx.h”?错误解决办法

    VS中出现是否忘记了向源中添加"#include "stdafx.h""?的错误解决办法 经常在用VS来写项目时,会出现这一问题. 在经过相关资料的查阅之后,发 ...

最新文章

  1. SimpleDelegate 委托
  2. Session Sticky
  3. jquery的disabled
  4. 农产品谋定创意种植-农业大健康·焦裕良:新概念新创意
  5. python gdb coredump_Linux段错误及GDB Coredump调试方法
  6. java ee maven_针对新手的Java EE7和Maven项目–第6部分
  7. 小程序 报错 err code: 40029, errmsg: 'invalid code, hints: [ req_id: JhIay6yFe-XN5A3 ]'
  8. 计算机和网络老是断开,电脑插上网线还是显示断开连接怎么办
  9. Ubuntu作为服务器其tomcat被远程访问问题
  10. 上万规模数据湖如何在实验室测试
  11. Windows -- Qt不能进行调试 -- Unknown debugger type No Engine
  12. 科技公司 CEO 合谋“诈骗”自家公司超 900 万美元,现已被捕
  13. java 打文件传输超时_java I/O 一次批量插入保存文件,导致超时问题?
  14. Mac上终端的命令总结
  15. ubuntu终端命令停止_解决Linux关闭终端(关闭SSH等)后运行的程序或者服务自动停止【后台运行程序】...
  16. 迅捷pdf转换器——PDF批量转化成JPG
  17. 抖音去水印最新php方法代码
  18. 业务太忙,真的是没时间搞自动化理由吗?
  19. 调研内容(算法相关--MDP)
  20. 【算法竞赛入门经典】习题1-4:正弦和余弦

热门文章

  1. 数据结构 - 2 树 - 1 概述
  2. 微信小程序评分组件Rate
  3. Java探针--javaagent--使用/实例
  4. 小巧上班通勤必备真无线蓝牙耳机,音质动听颜值在线,机不可失
  5. linux 企业版系统安装教程,红帽企业版Linux 6安装指南(中文)
  6. Nature子刊:功能性脑架构与阿尔兹海默症tau蛋白聚集速率有关
  7. 商标注册流程,商标注册材料
  8. 笔记本电脑连接手机热点,显示网络受限上不了网解决方法
  9. H5视频播放器开发-画中画
  10. 用量子计算机创造史上首个虫洞 加州理工学院团队发Nature封面文章