Tangwx

Tangwx

博客网站

Writing stm32 code with code completion function by configuring C_C++ plugin for VScode offline installation.

Configuring Code Prompt Function for Writing STM32 Code with Offline Installation of C/C++ Plugin in VScode#

1. Installing MinGW#

1.1 Downloading MinGW#

Download MinGW from the official website

  • Online Installation - Download MinGW-W64-install.exe (slow speed)

  • Downloading Compressed Package - ×86_64-posix-sjlj (fast speed)

    image-20230615085403173

1.2. Placing the Downloaded Files in a Convenient Directory and Copying the Path of the bin Directory#

Here, I extracted the compressed package to the D:\MinGW\mingw64 folder.
image-20230615085627058

Copy the path of the bin folder, which is D:\MinGW\mingw64\bin in my case.

image-20230615085641192

1.3. Configuring Environment Variables#

Right-click on "This PC" -> Properties -> Advanced system settings -> Environment Variables -> Path

image-20230615085934463

Click on Edit -> New

image-20230615090102117

Paste the copied path of the bin folder

image-20230615090159406

Click OK

1.4. Verifying MinGW Configuration#

Open cmd and enter gcc -v or g++ -v

image-20230615090402128

image-20230615090414764

You can see that the versions of gcc and g++ are both 8.1.0, indicating a successful installation.

2. Configuring C/C++ Plugin in VScode#

Since the computer with VScode installed does not have internet access, I will use the offline installation method to install the C/C++ plugin.

Go to Visual Studio Marketplace VScode Extensions, search for C/C++, and select the first one.

image-20230615090830200

Double-click to enter and find the Download Extension in the bottom right corner.

image-20230615090924767

Open VScode and go to the Extensions Manager.

image-20230615091111672

Click on "Install from VSIX" and select the extension file we just downloaded.

image-20230615091245394

Wait for the import to finish, and you can see that the C/C++ extension installation is completed.

image-20230615091222523

3. Configuring C/C++ Environment#

3.1 Configuring the Compiler#

Next, configure the compiler path. Press Ctrl+Shift+P to bring up the command palette, enter C/C++, and select "Edit Configurations(UI)" to enter the configuration.

image-20230615091613000

Add the header file paths in the project and configure global macro definitions. This way, you can use the code prompt function without errors.

image-20230615110426098

3.2 Setting the File Opening Format#

Press Ctrl+Shift+P to bring up the command palette, enter settings, and find "Open User Settings" function.

Enter encoding and configure the file opening format as GB2312.

image-20230615110937695

Now you can happily use VScode to edit code with the code prompt function. After writing the code, you can compile, debug, and download it in Keil for convenient development.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.