How to configure C/C++ project folder for Pi Pico so that the correct compiler is used? (Windows)

  raspberry-pi-pico, windows

I started playing with Pi Pico a few days ago.

Because my day job requires a Windows machine, I followed Youtube tutorial (https://www.youtube.com/watch?v=mUF9xjDtFfY) and successfully set up GNU Gcc for Arm, VS Building Tools (I had them already on my PC for other purpose), Pico SDK and the examples. Everything worked except the VS Code setup (not important – build can be done from command line, also, this is not related to my problem).

As the next step, I modified one of the examples, successfully built it, uploaded and tested. Everything OK.

Following instructions given in another tutorial (https://www.youtube.com/watch?v=Q1Kfg8k54jM) I created a new project folder.

   pico-root
   |
   +-- pico-projects
   |   |
   |   +-- build
   |
   +-- pico-sdk ...
   |
   +-- pico-examples ...

The only difference against the video is that I do not use CMake Tools plugin in VS Code (it generates invalid make files) but I do build from command line individually invoking CMake and NMake. I copied pico_sdk_import.cmake from pico-examples, as recommended in the tutorial.

And here I am stuck. Every time I run CMake -G "NMake Makefiles" .., CMake should determine what compiler is to be used. In pico-examples it correctly finds GCC for ARM (its location is in the first position in PATH environmnent variable), identified as GNU:

-- 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

but in my project folder pico-projectsbuild when I start the same command, it finds MSVC instead:

-- The C compiler identification is MSVC 19.28.29337.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29333/bin/Hostx86/x86/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
Using PICO_SDK_PATH from environment ('....pico-sdk')
PICO_SDK_PATH is C:/Users/jvavruska/dev/@RAS-PICO/pico-sdk
Defaulting PICO_PLATFORM to rp2040 since not specified.
Defaulting PICO platform compiler to pico_arm_gcc since not specified.
PICO compiler is pico_arm_gcc
-- The CXX compiler identification is MSVC 19.28.29337.0
-- The ASM compiler identification is MSVC
-- Found assembler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29333/bin/Hostx86/x86/cl.exe

Where is the difference? It is the same instance of Developer command prompt, i.e. same environment, etc.

Source: Windows Questions

LEAVE A COMMENT