Pico C/C++ Windows Tutorial 1
Environment Setting
Install arm gcc compiler
Download the webpage
Here I choose the same 2019-q4 version as the official one, and the operating system I use is Win10, so I choose:
gcc-arm-none-eabi-9-2019-q4-major-win32-sha2.exe
Note: Remember to add the path to the environment variable when installing.
Install Cmake
There is no special matter, it can be installed by default.
Install Visual Studio2019 (be sure to install 2019, different versions may cause it to fail to compile)
Install the corresponding components
- MSVC
- Windows 10 SDK (10.0.18362.0)
- C++ Cmake tool for windows
- Testing tool core features -Build Tools
- C++ AddressSanitizer(Experimental)
Install Python 3.7
Remember to add the path to the environment variable when installing (if it can be shown that the maximum PATH length can be removed, remove it).
- If the build fails because make cannot find Python, you should add the symlink to the executable.
1. Type cmd in the Run window next to the Windows menu to open the developer command prompt window, right-click and select "Run as administrator" to open the window with administrator privileges.
2. Navigate to the python installation directory, where the default address is C:\Users\[username]\AppData\Local\Programs\Python\Python37
3. Then run the following command:
Install Git
The specific installation tutorial will be written separately. Here is just a simple text explanation:
- Allow git to use third-party tools (checkbox to allow Git to be used from third-party tools)
- Select "Checkout as is, commit as-is"
- Select "Use Windows' default console window"
- Select "Enable experimental support for pseudo consoles"
Configure PICO-SDK
Get PICO-SDK and PICO-EXAMPLES
- In a file of the SDK and Examples you want to store, it is recommended that the path be short .
- Open the git command line and enter the following command
git clone -b master https://github.com/raspberrypi/pico-sdk.git git clone -b master https://github.com/raspberrypi/pico-examples.git
Initialize, grab and check out any nested submodules (must be run, otherwise it won't compile).
cd pico-sdk git submodule update --init --recursive
Set PICO Path
- Open Visual Studio 2019.
- Tools -> Command Line -> Developer PowerShell Input.
setx PICO_SDK_PATH "[the path to store PICO-SDK]\pico-sdk"
Or use the official method (this method must use the relative path of the official storage folder).
setx PICO_SDK_PATH "..\..\pico-sdk"
Configure the Demo
Restart developer PowerShell input
cd [the path to store Pico-example]\pico-examples mkdir build cd build cmake -G "NMake Makefiles" .. nmake
Possible Problems
- 'nmake' is not an internal or external command, nor is it a runnable program.
- Visual Studio 2019 does not install the correct corresponding components.
- Developer PowerShell not opening in Visual Studio 2019.
- cl.exe appears in the error message.
- Visual Studio non-2019 version
- The component version selection is wrong, there are detailed instructions above
- Cmake file ***
- Empty the build folder and recompile
Visual Studio Code Environment Setting
Install Visual Studio Code
https://visualstudio.microsoft.com/zh-hans/downloads/
Install the plugin
- Open the Visual Studio Code extension interface (shortcut Ctrl+Shift+X).
- Enter CMake Tools and install.
- F1 Enter open settings UI to open the settings UI interface.
4. Search for cmake.configureEnvironment.
5. Add item:
Item | Value |
---|---|
PICO_SDK_PATH | (the path to store PICO-SDK)\pico-sdk |
Or (this method must use the relative path of the official storage folder)
Item | Value |
---|---|
PICO_SDK_PATH | ..\..\pico-sdk |
Compile with Visual Studio Code
- Note: Be sure to reopen Visual Studio Code using Visual Studio 2019's developer command line, as follows:
- Open Visual Studio 2019
- Tools -> Command Line -> Developer PowerShell Input:
code
- Compile tool.2. Build 3. The projects to compile.
Open the pico-examples folder, select the compilation tool at the bottom as "GCC for arm-none-eabi", then select the project you want to compile, and finally click the build button.
- CMake.exe reports an error or an error about CMakefile
1. Empty the build folder, restart Visual Studio Code and recompile.
- Error about pioasm.exe.
2. The corresponding project may not be selected.
- The compilation passed for the first time, and the error message "FindFirstFileExA" was reported later.
3. Search for cmake.generator in the settings and fill in:
NMake Makefiles
Ctrl+S saves the settings, clears the build folder, restarts Visual Studio Code and recompiles.