由于 Nmake 错误,Raspberry pico 无法编译

Posted

技术标签:

【中文标题】由于 Nmake 错误,Raspberry pico 无法编译【英文标题】:Raspberry pico cannot compile due to Nmake error 【发布时间】:2021-02-22 09:20:06 【问题描述】:

我正在尝试设置环境为新 PICO 开发一些程序,但在出现此错误后只编译一次:

[main] Building folder: pico-examples 
[build] Starting build
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/pico/pico-examples/build --config Debug --target blink --
[build] Scanning dependencies of target bs2_default
[build] [  0%] Built target bs2_default
[build] [  0%] Built target bs2_default_padded_checksummed_asm
[build] [  0%] Performing build step for 'ELF2UF2Build'
[build] 
[build] Microsoft (R) Program Maintenance Utility Version 14.28.29337.0
[build] Copyright (C) Microsoft Corporation.  All rights reserved.
[build] 
[build] [100%] Built target elf2uf2
[build] [  0%] No install step for 'ELF2UF2Build'
[build] [  0%] Completed 'ELF2UF2Build'
[build] [  0%] Built target ELF2UF2Build
[build] Scanning dependencies of target blink
[build] Consolidate compiler generated dependencies of target blink
[build] blink\CMakeFiles\blink.dir\compiler_depend.make(4) : fatal error U1033: syntax error : ':' unexpected
[build] Stop.
[build] NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX86\x86\Nmake.exe"' : return code '0x2'
[build] Stop.
[build] NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX86\x86\Nmake.exe"' : return code '0x2'
[build] Stop.
[build] NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX86\x86\Nmake.exe"' : return code '0x2'
[build] Stop.
[build] Build finished with exit code 2

我正在从 Raspberry SDK 编译它的标准示例的 Blink 应用程序:

#include "pico/stdlib.h"

int main() 
    const uint LED_PIN = 25;
    gpio_init(LED_PIN);
    gpio_set_dir(LED_PIN, GPIO_OUT);
    while (true) 
        gpio_put(LED_PIN, 1);
        sleep_ms(250);
        gpio_put(LED_PIN, 0);
        sleep_ms(250);
    





我已经安装了 VS 代码,并且在为此 PICO 安装了 VS 2019 之后。我一步一步地按照 Raspberry 的文档(开始使用 Raspberry PICO)进行操作。也由 VS2019 的命令提示符启动。

我尝试单独安装最后一个 Windows SDK,我还重新安装了 Visual Studio。但还是一样。

有人可以在这个话题上帮助我吗?这个问题我睡不着:(

自动生成的文件有什么问题示例:

# CMAKE generated file: DO NOT EDIT!
# Generated by "NMake Makefiles" Generator, CMake Version 3.20

blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: C:\pico\pico-sdk\src\common\pico_sync\critical_section.c
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: C\:\pico\pico-sdk\src\common\pico_sync\critical_section.c
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: C\:\pico\pico-sdk\src\common\pico_sync\include\pico\critical_section.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: C\:\pico\pico-sdk\src\common\pico_sync\include\pico\lock_core.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: C\:\pico\pico-sdk\src\common\pico_base\include\pico.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: C\:\pico\pico-sdk\src\common\pico_base\include\pico\types.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: c\:\progra~2\gnuarm~1\102020~1\lib\gcc\arm-none-eabi\10.2.1\include\stdint.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\stdint.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\machine\_default_types.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\sys\features.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\_newlib_version.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\sys\_intsup.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\sys\_stdint.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: c\:\progra~2\gnuarm~1\102020~1\lib\gcc\arm-none-eabi\10.2.1\include\stdbool.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: c\:\progra~2\gnuarm~1\102020~1\lib\gcc\arm-none-eabi\10.2.1\include\stddef.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: C\:\pico\pico-examples\build\generated\pico_base\pico\version.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: C\:\pico\pico-sdk\src\common\pico_base\include\pico\config.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: C\:\pico\pico-examples\build\generated\pico_base\pico\config_autogen.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: C\:\pico\pico-sdk\src\boards\include\boards\pico.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\common\pico_sync
...

blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_float\float_init_rom.c.obj: C\:\pico\pico-sdk\src\common\pico_base\include\pico.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_float\float_init_rom.c.obj: C\:\pico\pico-sdk\src\common\pico_base\include\pico\types.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_float\float_init_rom.c.obj: c\:\progra~2\gnuarm~1\102020~1\lib\gcc\arm-none-eabi\10.2.1\include\stdint.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_float\float_init_rom.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\stdint.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_float\float_init_rom.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\sys\_intsup.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_float\float_init_rom.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\sys\_stdint.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_float\float_init_rom.c.obj: c\:\progra~2\gnuarm~1\102020~1\lib\gcc\arm-none-eabi\10.2.1\include\stdbool.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_float\float_init_rom.c.obj: C\:\pico\pico-examples\build\generated\pico_base\pico\version.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_float\float_init_rom.c.obj: C\:\pico\pico-sdk\src\common\pico_base\include\pico\config.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_float\float_init_rom.c.obj: C\:\pico\pico-examples\build\generated\pico_base\pico\config_autogen.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_float\float_init_rom.c.obj: C\:\pico\pico-sdk\src\boards\include\boards\pico.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_float\float_init_rom.c.obj: C\:\pico\pico-sdk\src\rp2_common\pico_platform\include\pico\platform.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_float.
...
.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\machine\_default_types.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_printf\printf.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\sys\features.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_printf\printf.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\_newlib_version.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_printf\printf.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\sys\_intsup.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_printf\printf.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\sys\_stdint.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_printf\printf.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\stdio.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_printf\printf.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\_ansi.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_printf\printf.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\newlib.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_printf\printf.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\sys\config.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_printf\printf.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\machine\ieeefp.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_printf\printf.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\sys\cdefs.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_printf\printf.c.obj: c\:\progra~2\gnuarm~1\102020~1\lib\gcc\arm-none-eabi\10.2.1\include\stddef.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_printf\printf.c.obj: c\:\progra~2\gnuarm~1\102020~1\lib\gcc\arm-none-eabi\10.2.1\include\stdarg.h
blink\CMakeFiles\blink.dir\C_\pico\pico-sdk\src\rp2_common\pico_printf\printf.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\sys\reent.h

blink\CMakeFiles\blink.dir\blink.c.obj: C\:\pico\pico-sdk\src\rp2_common\pico_platform\include\pico\platform.h
blink\CMakeFiles\blink.dir\blink.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\sys\cdefs.h
blink\CMakeFiles\blink.dir\blink.c.obj: C\:\pico\pico-sdk\src\common\pico_base\include\pico\types.h
blink\CMakeFiles\blink.dir\blink.c.obj: C\:\pico\pico-sdk\src\rp2040\hardware_regs\include\hardware\platform_defs.h
blink\CMakeFiles\blink.dir\blink.c.obj: C\:\pico\pico-sdk\src\rp2040\hardware_regs\include\hardware\regs\addressmap.h
blink\CMakeFiles\blink.dir\blink.c.obj: C\:\pico\pico-sdk\src\common\pico_base\include\pico\assert.h
blink\CMakeFiles\blink.dir\blink.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\assert.h
blink\CMakeFiles\blink.dir\blink.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\_ansi.h
blink\CMakeFiles\blink.dir\blink.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\newlib.h
blink\CMakeFiles\blink.dir\blink.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\sys\config.h
blink\CMakeFiles\blink.dir\blink.c.obj: c\:\progra~2\gnuarm~1\102020~1\arm-none-eabi\include\machine\ieeefp.h
blink\CMakeFiles\blink.dir\blink.c.obj: C\:\pico\pico-sdk\src\common\pico_base\include\pico\error.h
blink\CMakeFiles\blink.dir\blink.c.obj: C\:\pico\pico-sdk\src\rp2_common\pico_stdio\include\pico\stdio.h
blink\CMakeFiles\blink.dir\blink.c.obj: C\:\pico\pico-sdk\src\common\pico_time\include\pico\time.h
blink\CMakeFiles\blink.dir\blink.c.obj: C\:\pico\pico-sdk\src\rp2_common\hardware_timer\include\hardware\timer.h
blink\CMakeFiles\blink.dir\blink.c.obj: C\:\pico\pico-sdk\src\rp2040\hardware_structs\include\hardware\structs\timer.h
blink\CMakeFiles\blink.dir\blink.c.obj: C\:\pico\pico-sdk\src\rp2_common\ha
C:\pico\pico-sdk\src\rp2_common\hardware_vreg\vreg.c:

C\:\pico\pico-sdk\src\rp2_common\hardware_vreg\vreg.c:

C\:\pico\pico-sdk\src\rp2_common\hardware_vreg\include\hardware\vreg.h:

C\:\pico\pico-sdk\src\rp2040\hardware_structs\include\hardware\structs\vreg_and_chip_reset.h:

C\:\pico\pico-sdk\src\rp2040\hardware_regs\include\hardware\regs\vreg_and_chip_reset.h:

C:\pico\pico-sdk\src\rp2_common\hardware_watchdog\watchdog.c:

C\:\pico\pico-sdk\src\rp2_common\hardware_watchdog\watchdog.c:

C\:\pico\pico-sdk\src\rp2040\hardware_structs\include\hardware\structs\watchdog.h:

C\:\pico\pico-sdk\src\rp2040\hardware_regs\include\hardware\regs\watchdog.h:

C\:\pico\pico-sdk\src\rp2040\hardware_structs\include\hardware\structs\psm.h:

C\:\pico\pico-sdk\src\rp2040\hardware_regs\include\hardware\regs\psm.h:

C\:\pico\pico-sdk\src\rp2_common\hardware_xosc\xosc.c:

C\:\pico\pico-sdk\src\rp2_common\pico_stdio_uart\stdio_uart.c:

C\:\pico\pico-sdk\src\rp2_common\pico_bootrom\bootrom.c:

C\:\pico\pico-sdk\src\rp2_common\pico_bootrom\include\pico\bootrom.h:

C\:\pico\pico-sdk\src\rp2_common\pico_double\double_init_rom.c:


提前致谢。 最好的问候

【问题讨论】:

欢迎来到 SO!错误说明:[build] blink\CMakeFiles\blink.dir\compiler_depend.make(4) : fatal error U1033: syntax error : ':' unexpected,所以您的代码中有错字。请包含代码,以便用户查看导致错误的原因。 @fth:不太可能。发生错误的文件是自动生成的,因此不应包含任何语法错误。我会尝试一个干净的构建。 是的,我更新了文件自动生成的内容,感谢您的帮助 没问题@NachFenix 【参考方案1】:

好的,解决方案是从自动生成的文件中删除内容,保存文件并重新构建...,

在多次构建后再次出现错误,同样的过程是成功的:D

感谢所有试图帮助我的人,如果知道根问题会很棒!

【讨论】:

【参考方案2】:

我自己尝试在 VS Code 中编译时遇到了同样的问题,第一遍工作正常,任何重新编译都失败并出现同样的错误。

错误的原因是包含错误转义路径的 compiler_depend.make 文件。它试图转义 : 在 Windows 驱动器号之后。它不会对每个部分中的第一个条目执行此操作,尽管该条目与每个部分中的第二个条目使用不正确的路径重复。

例如

blink\CMakeFiles\blink.dir\D_\projects\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: D\:\projects\pico\pico-sdk\src\common\pico_sync\critical_section.c

应该是

blink\CMakeFiles\blink.dir\D_\projects\pico\pico-sdk\src\common\pico_sync\critical_section.c.obj: D:\projects\pico\pico-sdk\src\common\pico_sync\critical_section.c

目前我目前的快速修复是在所有 compiler_depend.make 文件中将“\:”替换为“:”

【讨论】:

@NachFenix 我已经找到了根本原因,它似乎是 CMake 3.20.0 的候选版本有问题。我卸载了它并安装了 CMakle 3.19.6,发现 VC 中的初始构建和重建工作 100% 没有错误。文件路径的错误转义不存在。【参考方案3】:

这是已经提到的解决方案(删除 /build 的内容)作为重建 DOS 命令,适用于那些不太了解它的人。从 build 文件夹运行它。

del /q /s * && cmake .. -G "NMake Makefiles" && nmake

【讨论】:

【参考方案4】:

卸载当前的 CMAKE 版本并从这里安装 3.20 版本: https://cmake.org/files/v3.20/

不要忘记将 CMAKE 添加到路径

【讨论】:

您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center。

以上是关于由于 Nmake 错误,Raspberry pico 无法编译的主要内容,如果未能解决你的问题,请参考以下文章

Raspberry Pyusb 资源繁忙

nmake : NMAKE : 致命错误 U1073: 不知道如何制作 '"C:/Program Files (x86)/Git/nologo"'

“NMAKE:致命错误 u1073”的修复方法是啥?

NMAKE 静态链接错误

nmake 编译错误

nmake - 关于转义的简单问题