1

I'm trying to build the examples for RP pico using Visual Studio Code 2022 on windows 11.

I have been following the "Getting started with raspberry pi pico" document and have succeeded up to the point where the nmake command is used to build the examples using developer command prompt. It seems the first hurdle is "Detecting C compiler ABI info - failed" please see below for full output. I have searched all over the internet and stack overflow and tried various peoples fixes but nothing seems to help.

I have tried: Setting cl.exe as administrator
Running developer command prompt as admin
Reinstalling VS code and cmake
Manually installed windows sdk (as it's not an option on the MSVC installer)
Running VsDevCmd.bat which fails with "Encountered errors" but nothing more useful. I have run the debug and output to txt file but I don't know what I'm looking at.

Thanks in advance.


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

[  0%] Built target bs2_default
[  0%] Built target bs2_default_padded_checksummed_asm
[  0%] Performing configure step for 'ELF2UF2Build'
-- The C compiler identification is MSVC 19.32.31329.0
-- The CXX compiler identification is MSVC 19.32.31329.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.23/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe"

  is not able to compile a simple test program.

  It fails with the following output:

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

    Run Build Command(s):nmake -f Makefile /nologo cmTC_add02\fast &&   "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.32.31326\bin\Hostx64\x64\nmake.exe"  -f CMakeFiles\cmTC_add02.dir\build.make /nologo -L                  CMakeFiles\cmTC_add02.dir\build
    Building C object CMakeFiles/cmTC_add02.dir/testCCompiler.c.obj
        "C:\Program Files\CMake\bin\cmake.exe" -E cmake_cl_compile_depends --dep-file=CMakeFiles\cmTC_add02.dir\testCCompiler.c.obj.d --working-dir=C:\pico\Downloads\pico-examples\build\elf2uf2\CMakeFiles\CMakeTmp --filter-prefix="Note: including file: " -- C:\PROGRA~2\MICROS~4\2022\BUILDT~1\VC\Tools\MSVC\1432~1.313\bin\Hostx64\x64\cl.exe @C:\Users\Dan\AppData\Local\Temp\nmE440.tmp
    testCCompiler.c
    Linking C executable cmTC_add02.exe
        "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_add02.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x86\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x86\mt.exe --manifests -- C:\PROGRA~2\MICROS~4\2022\BUILDT~1\VC\Tools\MSVC\1432~1.313\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_add02.dir\objects1.rsp @C:\Users\Dan\AppData\Local\Temp\nmE49F.tmp
    LINK Pass 1: command "C:\PROGRA~2\MICROS~4\2022\BUILDT~1\VC\Tools\MSVC\1432~1.313\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_add02.dir\objects1.rsp /out:cmTC_add02.exe /implib:cmTC_add02.lib /pdb:C:\pico\Downloads\pico-examples\build\elf2uf2\CMakeFiles\CMakeTmp\cmTC_add02.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_add02.dir/intermediate.manifest CMakeFiles\cmTC_add02.dir/manifest.res" failed (exit code 1104) with the following output:
    LINK : fatal error LNK1104: cannot open file 'MSVCRTD.lib'
    NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : return code '0xffffffff'
    Stop.
    NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.32.31326\bin\Hostx64\x64\nmake.exe"' : return code '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:/pico/Downloads/pico-examples/build/elf2uf2/CMakeFiles/CMakeOutput.log".
See also "C:/pico/Downloads/pico-examples/build/elf2uf2/CMakeFiles/CMakeError.log".
NMAKE : fatal error U1077: 'echo' : return code '0x1'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.32.31326\bin\Hostx64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.32.31326\bin\Hostx64\x64\nmake.exe"' : return code '0x2'
Stop.
Jonas
  • 121,568
  • 97
  • 310
  • 388
  • After a day of trying to get this working I just gave up (kinda). I used MinGW instead and used this excellent guide: https://shawnhymel.com/2096/how-to-set-up-raspberry-pi-pico-c-c-toolchain-on-windows-with-vs-code/ – AlphaModular Jun 07 '22 at 19:03
  • You're issuing a debug build. *MSVC Redist* debug version is not actually redistributable, and may not be included by default. Try with a release build. But I don't think that's it. Seems that build files are out of date. – CristiFati Aug 15 '22 at 21:47

1 Answers1

0

I had a pretty similar issue in my project with Ninja.

The compilation is triggered with the next bat file (it's not full, just a part to generate CMake cache):

@echo off
SETLOCAL

set BUILD_TYPE=%~1
IF NOT "%BUILD_TYPE%"=="" GOTO BUILD_TYPE_OK
set BUILD_TYPE=Debug
:BUILD_TYPE_OK

set CMAKE_MAKE_PROGRAM=C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe
set C_COMPILER=C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe
set CXX_COMPILER=C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe

echo Build type: %BUILD_TYPE%
echo SBP_SBP_MSVC_QT64_DIR  = %SBP_SBP_MSVC_QT64_DIR%

set PATH_X64=%PATH%;%SBP_SBP_MSVC_QT64_DIR%
set PATH=%PATH_X64%
cmake -DCMAKE_BUILD_TYPE=%BUILD_TYPE% "-DCMAKE_MAKE_PROGRAM=%CMAKE_MAKE_PROGRAM%" "-DCMAKE_C_COMPILER=%C_COMPILER%" "-DCMAKE_CXX_COMPILER=%CXX_COMPILER%" -DPDB_DIR=../deploy-pdb/x64 -DCMAKE_INSTALL_PREFIX=../deploy/bin-x64 -G Ninja -S . -B ../build/x64
if %errorlevel% neq 0 exit /b %errorlevel%

echo Done.
ENDLOCAL

The original output looked like this:

Build type: Debug
SBP_SBP_MSVC_QT64_DIR  = c:\Qt\5.15.2\msvc2019_64
-- The C compiler identification is MSVC 19.32.31332.0
-- The CXX compiler identification is MSVC 19.32.31332.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.24/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: D:/Job/Code/Subpac/x1c1-multitool/build/x64/CMakeFiles/CMakeTmp

    Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_3975f && [1/2] Building C object CMakeFiles\cmTC_3975f.dir\testCCompiler.c.obj
    [2/2] Linking C executable cmTC_3975f.exe
    FAILED: cmTC_3975f.exe
    cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_3975f.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests  -- C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1432~1.313\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_3975f.dir\testCCompiler.c.obj  /out:cmTC_3975f.exe /implib:cmTC_3975f.lib /pdb:cmTC_3975f.pdb /version:0.0 /machine:x64  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
    RC Pass 1: command "rc /fo CMakeFiles\cmTC_3975f.dir/manifest.res CMakeFiles\cmTC_3975f.dir/manifest.rc" failed (exit code 0) with the following output:
    The system cannot find the file specified
    ninja: build stopped: subcommand failed.





  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 "D:/Test/build/x64/CMakeFiles/CMakeOutput.log".
See also "D:/Test/build/x64/CMakeFiles/CMakeError.log".

[process exited with code 1 (0x00000001)]

The issue was fixed when I added the next line to the build script: call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64. Below the part of the bat file with this line added:

@echo off
SETLOCAL

set BUILD_TYPE=%~1
IF NOT "%BUILD_TYPE%"=="" GOTO BUILD_TYPE_OK
set BUILD_TYPE=Debug
:BUILD_TYPE_OK

call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64

set CMAKE_MAKE_PROGRAM=C:/Program Files/Microsoft Visual Studio/2022....

Now the output looks like this, and when I add commands to deploy, all works fine:

**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.2.6
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
Build type: Debug
SBP_SBP_MSVC_QT64_DIR  = c:\Qt\5.15.2\msvc2019_64
-- The C compiler identification is MSVC 19.32.31332.0
-- The CXX compiler identification is MSVC 19.32.31332.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Test/build/x64
Done.

Hope it will help to solve your problem with nmake.