星海露水 2024-02-08 00:50 采纳率: 68.8%
浏览 5

vscode搭建树莓派环景报错

`

`CMake Error at E:/Program Files/CMake/share/cmake-3.28/Modules/CMakeTestCCompiler.cmake:67 (message):
[cmake]   The C compiler
[cmake] 
[cmake]     "E:/mingw64/bin/gcc.exe"
[cmake] 
[cmake]   is not able to compile a simple test program.
[cmake] 
[cmake]   It fails with the following output:
[cmake] 
[cmake]     Change Dir: 'G:/Arduino/pico-examples-master/build/CMakeFiles/CMakeScratch/TryCompile-2bdn3u'
[cmake]     
[cmake]     Run Build Command(s): "E:/Program Files/CMake/bin/cmake.exe" -E env VERBOSE=1 E:/mingw64/bin/mingw32-make.exe -f Makefile cmTC_51766/fast
[cmake]     E:/mingw64/bin/mingw32-make.exe  -f CMakeFiles\cmTC_51766.dir\build.make CMakeFiles/cmTC_51766.dir/build
[cmake]     mingw32-make.exe[1]: Entering directory 'G:/Arduino/pico-examples-master/build/CMakeFiles/CMakeScratch/TryCompile-2bdn3u'
[cmake]     Building C object CMakeFiles/cmTC_51766.dir/testCCompiler.c.obj
[cmake]     E:\mingw64\bin\gcc.exe   -mcpu=cortex-m0plus -mthumb  -o CMakeFiles\cmTC_51766.dir\testCCompiler.c.obj -c G:\Arduino\pico-examples-master\build\CMakeFiles\CMakeScratch\TryCompile-2bdn3u\testCCompiler.c
[cmake]     gcc.exe: warning: '-mcpu=' is deprecated; use '-mtune=' or '-march=' instead
[cmake]     gcc.exe: error: unrecognized command line option '-mthumb'; did you mean '-mtbm'?
[cmake]     mingw32-make.exe[1]: *** [CMakeFiles\cmTC_51766.dir\build.make:77: CMakeFiles/cmTC_51766.dir/testCCompiler.c.obj] Error 1
[cmake]     mingw32-make.exe[1]: Leaving directory 'G:/Arduino/pico-examples-master/build/CMakeFiles/CMakeScratch/TryCompile-2bdn3u'
[cmake]     mingw32-make.exe: *** [Makefile:126: cmTC_51766/fast] Error 2
[cmake]     
[cmake]     
[cmake] 
[cmake]   
[cmake] 
[cmake]   CMake will not be able to correctly generate this project.
[cmake] Call Stack (most recent call first):
[cmake]   CMakeLists.txt:8 (project)
[cmake] 
[cmake] `




```

  • 写回答

4条回答 默认 最新

  • 专家-郭老师 Java领域新星创作者 2024-02-08 00:51
    关注

    参考通义千问和郭老师的小迷弟雅思莫了-编写提供,主要是为了帮助您快速解决问题,如下回答,您可以参考下,如有问题,评论区留言。

    从错误信息来看,你尝试在Windows上使用MinGW的gcc编译器来为树莓派Pico(基于Cortex-M0+架构)构建项目,但是遇到了两个问题:

    1. gcc不识别-mthumb选项。 -mthumb是一个ARM架构的指令集选项,用于指定使用Thumb模式编译代码,这对于Cortex-M系列微控制器是必需的。但显然,你正在使用的MinGW版本的gcc并不支持这个选项。

    2. gcc提示-mcpu=cortex-m0plus已过时,并建议使用-mtune=-march=代替。尽管如此,它实际上并没有提供对Cortex-M0+内核的支持,因为MinGW主要针对的是x86架构,而非ARM架构。

    解决这个问题的方法是:

    • 使用专门为ARM Cortex-M系列设计的交叉编译工具链,如GNU Arm Embedded Toolchain,可以从Arm官网下载:https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm
    • 在VSCode中配置CMakeLists.txt文件以使用正确的交叉编译器路径,并确保相关的架构和CPU选项设置正确。例如:
    set(CMAKE_SYSTEM_NAME Generic)
    set(CMAKE_C_COMPILER arm-none-eabi-gcc)
    set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
    set(CMAKE_C_FLAGS "-mcpu=cortex-m0plus -mthumb")
    

    请根据你的实际环境调整这些配置。

    评论

报告相同问题?

问题事件

  • 创建了问题 2月8日

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?