Skip to content

1. VS Code Installation Steps

1
Download VS Code

Download from the official website: https://code.visualstudio.com/, choosing the version for your operating system:

  • Windows: choose the Windows version — .exe installer
  • macOS: choose the macOS version — .dmg image
  • Linux: choose .deb (Debian/Ubuntu) or .rpm (CentOS/RHEL) for your distribution, or the .tar.gz archive
2
Windows installation

Double-click the downloaded .exe file to start the wizard:

  1. Check I accept the agreement and click Next
  2. Choose the install location (the default is recommended, or use a path without non-ASCII characters)
  3. Key step: in Select Additional Tasks, make sure to check:
    • ✅ Add to PATH (so you can call the code command in the terminal)
    • ✅ Create a desktop icon
    • ✅ Register code as an editor for supported file types (optional, recommended for .cpp/.c)
  4. Click Install, wait for it to finish, then click Finish
3
macOS installation

Double-click the downloaded .dmg file and drag the VS Code icon into Applications; open Launchpad, find VS Code and launch it (first launch may ask for authorization — follow the prompts).

4
First-launch configuration

Open VS Code:

  • Choose a theme: click Color Theme and pick Dark+ (default dark) (easier on the eyes, better code contrast)
  • Skip the recommended extensions for now; configure the C/C++ extensions later

2. Essential C/C++ Extensions

Open VS Code, click the Extensions icon in the activity bar (or press Ctrl+Shift+X), type the extension name in the search box, find it and click Install.

ExtensionPublisherCore feature
C/C++MicrosoftOfficial core extension: syntax highlighting, IntelliSense, formatting and debugging for C/C++
C/C++ Extension PackMicrosoftExtension pack including C/C++, CMake Tools, etc. — installs all basics in one click
Code RunnerJun HanOne-click code running for C/C++ and many other languages
Doxygen Documentation GeneratorMarat DulinGenerates Doxygen documentation for comments and API docs
vscode-iconsvscode-icons-teamRich icons to make the file tree clearer
Serial MonitorMads KristensenSerial port tool for embedded/MCU debugging
CMake ToolsMicrosoftAuto-detects CMakeLists.txt with integrated build/debug support

Optional enhancements

  • GitLens: enhances Git integration — commit history, authorship, multi-developer collaboration
  • Better Comments: color-coded comments by type (warnings, TODO, notes)

3. SSH Remote Connection (Remote C Development)

1
Install the Remote-SSH extension

Search for Remote - SSH (by Microsoft) in the Extensions view and click Install. Afterwards a Remote Explorer icon (shaped like a monitor) appears in the activity bar.

2
Open the SSH config file

Click the Remote Explorer icon, click the Configure gear icon under SSH Targets, and choose the SSH config file path:

  • Windows: C:\Users\your-username\.ssh\config
  • macOS/Linux: ~/.ssh/config (created automatically if missing)
3
Write the configuration

Add the remote server information to the config file (adjust to your environment) and save (Ctrl+S):

# Custom host name (easy to remember, e.g., linux-server)
Host linux-server

# Remote server IP address or domain
HostName 192.168.1.100

# Login user name (must be an actual user on the server, not necessarily ubuntu)
User ubuntu

# SSH port (default 22; use the actual port if changed)
Port 22
4
Connect

In the Remote Explorer, find the host name you just configured under SSH Targets, right-click it and choose:

  • Connect to Host in Current Window: connect in the current window (closes the local project)
  • Connect to Host in New Window: connect in a new window (keeps the local project, recommended)
5
Verify your identity

The first connection asks you to select the platform (choose e.g. Linux); then enter the remote login password (nothing is shown while typing — press Enter when done); if asked Are you sure you want to continue connecting, type yes and press Enter. Once connected, SSH: host-name shows in the bottom-left corner.

Configure the C environment on the remote server

Once connected, VS Code shows the remote indicator (SSH: host-name in the bottom-left). Install the C compiler on the remote server:

You can install the same extensions on the remote server so you can switch between local and remote

1
Install compilers on Ubuntu/Debian

Open the VS Code integrated terminal (Ctrl+`) and run (gcc is the C compiler, g++ the C++ compiler, gdb the debugger):

sudo apt update && sudo apt install -y gcc g++ gdb
2
Install compilers on CentOS/RHEL

Run:

sudo yum install -y gcc gcc-c++ gdb
3
Verify the installation

Run gcc --version; a version line (e.g., gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0) means the installation succeeded.

gcc --version

4. Connect to WSL

1
Install WSL

Install WSL first — see the WSL installation tutorial

2
Install Ubuntu inside WSL

Then install the Ubuntu distribution — see the Ubuntu installation tutorial — WSL section

3
Install the WSL extension

Search for WSL (by Microsoft) in the Extensions view and click Install. Afterwards a Remote Explorer icon appears in the activity bar.

步骤 3 截图
4
Connect

In the Remote Explorer, find your distribution under WSL Targets (e.g., Ubuntu-20.04), right-click it and choose Connect to WSL (in the current or a new window).

On the first connection VS Code downloads the VS Code Server into WSL — please wait patiently.

FAQ

“gcc is not recognized as an internal or external command” (local Windows)

MinGW is not installed or not on PATH: download MinGW, check mingw32-gcc-g++ during installation, add MinGW's bin directory (e.g., C:\MinGW\bin) to the system Path variable, and restart VS Code.

SSH connection says “Permission denied”

Verify the user name and password (mind the case). If the server disallows password login, set up key-based auth: run ssh-keygen -t rsa locally (press Enter through the prompts), upload the public key with ssh-copy-id user@server-ip, and add an IdentityFile entry pointing to your local private key in the SSH config.

“Debugger not found” when debugging

The gdb debugger is missing: on local Windows, check mingw32-gdb in the MinGW installer; on the remote server, run sudo apt install gdb (or sudo yum install gdb).

Have questions?

For any other questions, visit the unified Q&A and discussion board: Ai-Thinker Discussions

Released under the MIT License. Build Time 2026-08-13 11:15:52