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

Raspberry pico cannot compile due to Nmake error

我正在尝试设置环境来为新的 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 Studio19\Community\VC\Tools\MSVC.28.29333\bin\HostX86\x86\Nmake.exe"' : return code '0x2'
[build] Stop.
[build] NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.28.29333\bin\HostX86\x86\Nmake.exe"' : return code '0x2'
[build] Stop.
[build] NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.28.29333\bin\HostX86\x86\Nmake.exe"' : return code '0x2'
[build] Stop.
[build] Build finished with exit code 2

我正在编译的 Blink 应用程序是来自 Raspberry SDK 的标准示例:

#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~12020~1\lib\gcc\arm-none-eabi.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~12020~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~12020~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~12020~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~12020~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~12020~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~12020~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~12020~1\lib\gcc\arm-none-eabi.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~12020~1\lib\gcc\arm-none-eabi.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~12020~1\lib\gcc\arm-none-eabi.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~12020~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~12020~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~12020~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~12020~1\lib\gcc\arm-none-eabi.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~12020~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~12020~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~12020~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~12020~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~12020~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~12020~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~12020~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~12020~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~12020~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~12020~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~12020~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~12020~1\lib\gcc\arm-none-eabi.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~12020~1\lib\gcc\arm-none-eabi.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~12020~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~12020~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~12020~1\arm-none-eabi\include\assert.h
blink\CMakeFiles\blink.dir\blink.c.obj: c\:\progra~2\gnuarm~12020~1\arm-none-eabi\include\_ansi.h
blink\CMakeFiles\blink.dir\blink.c.obj: c\:\progra~2\gnuarm~12020~1\arm-none-eabi\include\newlib.h
blink\CMakeFiles\blink.dir\blink.c.obj: c\:\progra~2\gnuarm~12020~1\arm-none-eabi\include\sys\config.h
blink\CMakeFiles\blink.dir\blink.c.obj: c\:\progra~2\gnuarm~12020~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:


提前致谢。 最好的问候

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

几次构建错误再次出现,同样的程序成功了:D

感谢所有试图帮助我的人,如果知道根问题就太好了!

我自己在 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 文件中的“\:”替换为“:”

这是已经提到的解决方案(删除 /build 的内容)作为重建 DOS 命令,供那些不太熟悉它的人使用。 运行 它来自构建文件夹。

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

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

不要忘记将 CMAKE 添加到路径