Sitemap
Dineth nimnaka

Dineth nimnaka

Set Up C Like a Professional in 15 Minutes (WSL + VS Code)

6 min readOct 5, 2026

--

There are 4 ways to set up C on your laptop In this article, we’ll focus on WSL with VS Code.

Why WSL? A real Linux system inside Windows, the best C tools in one command, and the same setup professionals use.

Step 1: Install WSL

  1. Press the Windows key, type PowerShell, right-click it, and choose Run as administrator.
Press enter or click to view image in full size

2. Run:

   wsl --install
  • The above command only works if WSL is not installed at all
  • wsl --install doesn't work? You can turn on WSL manually. Press the Windows key, type Turn Windows features on or off, and open it. Tick Windows Subsystem for Linux and Virtual Machine Platform, click OK, and restart your computer. Then run wsl --install again.
Turn Windows features on

3. Restart your computer when asked.

4. After the restart, an Ubuntu window usually opens by itself. Wait a minute for it to finish. If it doesn’t open, press the Windows key, type Ubuntu, and click the app.

Press enter or click to view image in full size
ubuntu window

5. Create a username (lowercase letters, no spaces) and a password. You’ll need this password later, so remember it. When you type the password, nothing shows on screen. That’s normal. Just type it, press Enter, then type it again to confirm.

Press enter or click to view image in full size

6. Check that WSL is installed

In the Ubuntu window, type this and press Enter:

wsl.exe --list --verbose

You should see something like this:

Press enter or click to view image in full size

Step 2: Install the C Compiler

WSL is ready, but it doesn’t have a C compiler yet. A compiler turns the C code you write into a program the computer can run. Let’s install one.

  1. In the Ubuntu window, type this and press Enter:
   sudo apt update
  • Enter your password if asked. (It won’t show as you type. That’s normal.)
Press enter or click to view image in full size

2. Then type this and press Enter:

   sudo apt install build-essential gdb

What does this install? Three tools that every C programmer uses:

  • GCC: turns your C code into a program (the compiler)
  • Make: builds bigger projects with one command
  • GDB: helps you find bugs (the debugger)
Press enter or click to view image in full size

Press Y and Enter when asked to continue. This takes a few minutes.

3. When it finishes, check that the compiler works:

   gcc --version
Press enter or click to view image in full size

Step 3: Install VS Code

What is VS Code? VS Code is a free code editor from Microsoft. It’s where you’ll write your C code. Download it from official website and install it with the default options.

Already have VS Code? Skip to the extensions in step 4.

Step 4: Install the Extensions

Extensions are small add-ons that give VS Code extra abilities. We need two.

  1. Open VS Code.
  2. Click the Extensions icon on the left side (the four squares), or press Ctrl + Shift + X.
  3. In the search box, type WSL, find WSL (by Microsoft), and click Install.
    This lets VS Code connect to your Ubuntu.
Press enter or click to view image in full size
WSL Extension
  1. Search for C/C++, find C/C++ (by Microsoft), and click Install.
    This adds code coloring, suggestions, and debugging for C.
Press enter or click to view image in full size

Step 5: Open Your Project in VS Code

There are two ways to open VS Code connected to Ubuntu. Pick whichever you prefer.

Get Dineth nimnaka’s stories in your inbox

Join Medium for free to get updates from this writer.

Method 1: Open it from the Ubuntu window (recommended)

In the Ubuntu window, type these commands one by one and press Enter after each:

cd ~
mkdir c-projects
cd c-projects
code .

What each command does:

  • cd ~ goes to your home folder in Ubuntu, so your project lives on the Linux side.
  • mkdir c-projects makes a new folder called c-projects. (mkdir means "make directory".)
  • cd c-projects moves you into that folder.
  • code . opens the current folder in VS Code. The . means "this folder".

“Installing VS Code Server… Downloading”? This is normal. The first time you run code ., VS Code installs a small helper inside Ubuntu so it can connect to Linux. It only happens once.

Press enter or click to view image in full size

Wait for it to reach 100% and VS Code will open by itself.

Press enter or click to view image in full size

Method 2: Open VS Code yourself

  1. Open VS Code from the Start menu.
  2. Click the >< icon in the bottom-left corner.
Press enter or click to view image in full size
  1. Choose Connect to WSL using Distro…
Press enter or click to view image in full size
Choose Connect to WSL using Distro…

then pick Ubuntu.

Press enter or click to view image in full size
This makes sure VS Code connects to the right Linux system.

Once the download reaches 100%, VS Code opens by itself.

Press enter or click to view image in full size

In the new window, click File → Open Folder…

Press enter or click to view image in full size

In the box, you’ll see your home folder, /home/yourname/. After it, type a name for your new folder, for example /home/yourname/my-first-c.

Press enter or click to view image in full size

Here, I’m creating a folder named C-Files. All my C programs will live in it.

Press enter or click to view image in full size
VS Code opened with the C-Files folder and WSL: Ubuntu in the bottom-left corner.

Step 6: Write Your First C Program

By now, you’ve opened VS Code using one of the two methods above: from the Ubuntu window (Method 1) or by connecting to WSL yourself (Method 2). You can use whichever method you like. Both give the same result.

Your folder is open and VS Code is connected to Ubuntu (check that the bottom-left corner says WSL: Ubuntu). Now let’s create your first C file. This works the same whichever method you used to open the folder.

Press enter or click to view image in full size
  1. In the Explorer panel on the left, move your mouse over the folder name (C-Files). Click the New File icon (a page with a plus sign).
  2. Type the file name hello.c and press Enter.
  3. Type this code into the file:
#include <stdio.h>

int main(void) {
printf("Hello, World!\n");
return 0;
}

4. Press Ctrl + S to save.

Press enter or click to view image in full size

Step 7: Compile and Run

  1. Open the terminal inside VS Code yourname@computer:~/C-Files$`.
  2. Compile your program:
   gcc hello.c -o hello

3. Run it:

   ./hello
Press enter or click to view image in full size

You just compiled and ran your first C program.

--

--