c-cpp-setup

C/C++ Setup on Windows

This guide will help you install everything you need to write and run C/C++ programs on Windows. Don’t worry if you’re new to this - we’ll go through each step carefully!

What We’re Installing and Why

MinGW = A free C/C++ compiler for Windows. Think of it as the tool that turns your C code into programs that can actually run on your computer.

Prerequisites (What You Need First)

Note: You can use tools from the resources folder, but I recommend downloading the latest versions from official websites.

Step 1: Download MinGW

MinGW is the compiler that will turn your C/C++ code into working programs.

  1. Go to the download page:
    • Visit SourceForge MinGW page
    • Look for a “Download Latest Version” button
    • Click it and wait for the download to start
    • The file will be called something like mingw-get-setup.exe
  2. Alternative: If the download is slow, check if mingw-get-setup.exe is available in your resources/windows/ folder

Step 2: Install MinGW

Now we’ll install the compiler on your computer.

  1. Run the installer:
    • Find the downloaded file (usually in your Downloads folder)
    • Double-click mingw-get-setup.exe
    • If Windows asks “Do you want to allow this app to make changes?”, click “Yes”
  2. Follow the installation wizard:
    • Click the “Install” button
    • Click “Continue”
    • Wait while it downloads some files (this might take a few minutes)
    • When it’s done, click “Continue” again
  3. Choose what to install:
    • You’ll see a window called “MinGW Installation Manager” with a list of packages
    • Find these two items in the list:
      • mingw32-base
      • mingw32-gcc-g++
    • For each one: Right-click on it and select “Mark for Installation”
    • You should see a small arrow or checkmark appear next to each one
  4. Install the selected packages:
    • Click “Installation” in the top menu
    • Click “Apply Changes”
    • Click “Apply” in the popup window
    • Wait for the installation to complete (this can take 5-10 minutes)
    • When it’s done, click “Close”
    • Close the MinGW Installation Manager window

Step 3: Add MinGW to Your System PATH

This step tells Windows where to find your new compiler. Don’t worry - it sounds technical but it’s just a few clicks!

What is PATH? It’s like giving Windows a map of where to find programs when you ask for them.

  1. Open Environment Variables:
    • Press the Windows key and type “environment variables”
    • Click on “Edit the system environment variables”
    • Click the “Environment Variables…” button at the bottom
  2. Edit the PATH:
    • In the bottom section (System variables), scroll down and find “Path”
    • Click on “Path” to select it
    • Click the “Edit…” button
    • Click “New” to add a new entry
    • Type: C:\MinGW\bin
    • Click “OK” three times to close all the windows

What did we just do? We told Windows that when you type compiler commands, it should look in the MinGW folder to find them.

Step 4: Test Your Installation

Let’s make sure everything is working properly!

  1. Open Command Prompt:
    • Press Windows key + R
    • Type cmd and press Enter
    • A black window will open - this is the Command Prompt
  2. Test the C compiler:
    • Type: gcc --version
    • Press Enter
    • You should see something like:
      gcc (MinGW.org GCC-6.3.0-1) 6.3.0
      Copyright (C) 2016 Free Software Foundation, Inc.
      
  3. Test the C++ compiler:
    • Type: g++ --version
    • Press Enter
    • You should see similar version information
  4. If both commands show version information, congratulations! Your setup is complete!

What if Something Goes Wrong?

Problem: “gcc is not recognized as an internal or external command”

This means Windows can’t find your compiler. Here’s how to fix it:

  1. Check if MinGW is installed:
    • Open File Explorer
    • Go to your C: drive
    • Look for a folder called “MinGW”
    • Inside MinGW, there should be a “bin” folder
    • Inside the bin folder, you should see files like gcc.exe and g++.exe
  2. If the MinGW folder exists but the command still doesn’t work:
    • Go back to Step 3 and double-check the PATH setup
    • Make sure you typed C:\MinGW\bin exactly (with correct slashes and capitalization)
    • Important: Close and reopen Command Prompt after changing PATH
  3. If MinGW folder doesn’t exist:
    • Go back to Step 2 and reinstall MinGW
    • Make sure you selected both packages and applied the changes

Problem: Downloads are very slow

Problem: “Access denied” errors

Quick Summary

Here’s what you just accomplished:

  1. Downloaded MinGW (your C/C++ compiler)
  2. Installed the compiler on your computer
  3. Told Windows where to find the compiler
  4. Tested that everything works

What’s Next?

Now that you have a working C/C++ compiler:

  1. Install VSCode - Follow the VSCode Setup Guide to get a nice editor
  2. Write your first program - Try creating a simple “Hello World” program
  3. Practice - The more you use it, the more comfortable you’ll become
  4. Optional: Graphics Programming - If you want to create graphical programs, check out Graphics Library Setup Guide

Understanding What You Installed

Your Windows computer is now ready for C/C++ programming!


Troubleshooting Tips:


Back to: Home Next: VSCode Setup Skip to: Graphics Setup