2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Windows Raspberry Pi Pico C/C++環境導入でハマったときの解決法

Posted at

#概要
Windowsで Raspberry Pi Pico C/C++環境導入しようとしたらエラーでハマったのでメモ

#環境
Windows 10 Home 64bit

#エラー
公式にあるGetting started with Raspberry Pi Picoの「9.2. Building on MS Windows」に沿ってインストールを進めていきビルドしようとしたところ下記のようなメッセージが出て途中で止まってしまいました。

C:\raspi_pico\pico-examples\build>cmake -G "NMake Makefiles" ..
Using PICO_SDK_PATH from environment ('C:\raspi_pico\pico-sdk')
PICO_SDK_PATH is C:/raspi_pico/pico-sdk
Defaulting PICO_PLATFORM to rp2040 since not specified.
Defaulting PICO platform compiler to pico_arm_gcc since not specified.
-- Defaulting build type to 'Release' since not specified.
PICO compiler is pico_arm_gcc
PICO_GCC_TRIPLE defaulted to arm-none-eabi
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- The ASM compiler identification is GNU
-- Found assembler: C:/Program Files (x86)/GNU Arm Embedded Toolchain/10 2020-q4-major/bin/arm-none-eabi-gcc.exe
Defaulting PICO target board to pico since not specified.
Using board configuration from C:/raspi_pico/pico-sdk/src/boards/include/boards/pico.h
-- Found Python3: C:/Program Files/WindowsApps/PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0/python3.9.exe (found version "3.9.5") found components: Interpreter
TinyUSB available at C:/raspi_pico/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; adding USB support.
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
ELF2UF2 will need to be built
PIOASM will need to be built
-- Configuring done
-- Generating done
-- Build files have been written to: C:/raspi_pico/pico-examples/build

C:\raspi_pico\pico-examples\build>nmake

Microsoft(R) Program Maintenance Utility Version 14.28.29915.0
Copyright (C) Microsoft Corporation.  All rights reserved.

Scanning dependencies of target bs2_default
[  0%] Building ASM object pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.obj
[  0%] Linking ASM executable bs2_default.elf
[  0%] Built target bs2_default
[  0%] Generating bs2_default.bin
[  0%] Generating bs2_default_padded_checksummed.S
[  0%] Built target bs2_default_padded_checksummed_asm
[  0%] Creating directories for 'ELF2UF2Build'
[  0%] No download step for 'ELF2UF2Build'
[  0%] No update step for 'ELF2UF2Build'
[  0%] No patch step for 'ELF2UF2Build'
[  0%] Performing configure step for 'ELF2UF2Build'
-- The C compiler identification is MSVC 19.28.29915.0
-- The CXX compiler identification is MSVC 19.28.29915.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29910/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29910/bin/Hostx86/x86/cl.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.20/Modules/CMakeTestCCompiler.cmake:66 (message):
  The C compiler

    "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29910/bin/Hostx86/x86/cl.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/raspi_pico/pico-examples/build/elf2uf2/CMakeFiles/CMakeTmp

    Run Build Command(s):nmake -f Makefile /nologo cmTC_1f9af\fast &&   "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\bin\HostX86\x86\nmake.exe"  -f CMakeFiles\cmTC_1f9af.dir\build.make /nologo -L                  CMakeFiles\cmTC_1f9af.dir\build
    Building C object CMakeFiles/cmTC_1f9af.dir/testCCompiler.c.obj
        "C:\Program Files\CMake\bin\cmake.exe" -E cmake_cl_compile_depends --dep-file=CMakeFiles\cmTC_1f9af.dir\testCCompiler.c.obj.d --working-dir=C:\raspi_pico\pico-examples\build\elf2uf2\CMakeFiles\CMakeTmp --filter-prefix="メモ: インク ルード ファイル:  " -- C:\PROGRA~2\MIB055~1\2019\BUILDT~1\VC\Tools\MSVC\1428~1.299\bin\Hostx86\x86\cl.exe @C:\Users\xxx\AppData\Local\Temp\nm6665.tmp
    testCCompiler.c
    Linking C executable cmTC_1f9af.exe
        "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_1f9af.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~2\MIB055~1\2019\BUILDT~1\VC\Tools\MSVC\1428~1.299\bin\Hostx86\x86\link.exe /nologo @CMakeFiles\cmTC_1f9af.dir\objects1.rsp @C:\Users\xxx\AppData\Local\Temp\nm66D3.tmp
    RC Pass 1: command "rc /fo CMakeFiles\cmTC_1f9af.dir/manifest.res CMakeFiles\cmTC_1f9af.dir/manifest.rc" failed (exit code 0) with the following output:
    指定されたファイルが見つかりません。NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : リターン  コード '0xffffffff'
    Stop.
    NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\bin\HostX86\x86\nmake.exe"' : リターン コード '0x2'
    Stop.





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- Configuring incomplete, errors occurred!
See also "C:/raspi_pico/pico-examples/build/elf2uf2/CMakeFiles/CMakeOutput.log".
See also "C:/raspi_pico/pico-examples/build/elf2uf2/CMakeFiles/CMakeError.log".
NMAKE : fatal error U1077: 'echo' : リターン コード '0x1'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\bin\HostX86\x86\nmake.exe"' : リターン コード '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\bin\HostX86\x86\nmake.exe"' : リターン コード '0x2'
Stop.

メッセージ通りCMakeError.logを確認してみると

/out:CMakeCCompilerId.exe 
CMakeCCompilerId.obj 
LINK : fatal error LNK1104: ファイル 'kernel32.lib' を開くことができません。

kernel32.libが見つけられないようでした。

#解決方法
解決方法を色々調べてWindowsSDKを入れ直したりしましたが、
最終的にはDeveloper Command Promptを管理者権限で実行することで無事ビルドに成功しました。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?