So You Wanna Do C++ Programming on Windows

You must update Win10 to the latest version before you will be able to enable the Windows Subsystem for Linux and Ubuntu (which is where you will find bash). It is best to do this over a wired connection as it will go faster and more smoothly.

Enable the subsystem:

  • Hit the Windows key and locate the Control Panel
  • Now locate the Programs and Features panel and double-click on it
  • Click the “Turn Windows features on or off” link on the left
  • Check the box for “Windows Subsystem for Linux” and click the “Ok” button

Install Ubuntu:

  • Hit the Windows key and locate Microsoft Store
  • Search for Ubuntu (“ubu” is probably sufficient)
  • Install Ubuntu (no need to sign in if prompted)

Enable developer mode:

  • Hit the Windows key and click the Settings gear on the left of the Start menu
  • Choose Update & Security (it’s the last entry)
  • Choose “For developers” on the left
  • Choose the “Developer mode” radio button

Reboot:

  • You’ve made some changes; time for a quick reboot
  • Once you are back, launch Ubuntu from the Windows menu and let it set itself up
  • If you let Ubuntu set itself up, these are the same steps as outlined in Setting up Bash

Setting up bash:

  • Open a command prompt (cmd), a PowerShell prompt, or a Terminal in Visual Studio Code (aka VSCode) and type bash
    • (This will cause bash to run through a basic set up.)
  • Enter new UNIX username:
    • Use your Windows username as that’s easiest to remember
  • Enter new UNIX password:
    • Use your login password for Windows again because it’s easiest
  • Retype your UNIX password:
    • Type your login password again so you’re sure it’s correct

If cmd complains bash doesn’t exist…

  • Open the Microsoft Store application
    • Win –> type store
  • Install Ubuntu
    • search for Ubuntu or bash
    • Click the “Get the apps” button in the “C:\> Linux on Windows?” box
    • Choose Ubuntu (free)
    • Click the “Get” button
  • Go back to “Setting up bash” above except you’ll need to locate and launch Ubuntu from the Windows Start menu

Update Ubuntu (the subsystem which is running bash):

  • sudo apt update
    • (you will be asked to invisibly enter your password)
  • sudo apt upgrade
    • (answer y)
  • sudo apt autoremove
  • sudo apt autoclean
  • # or simply use this:
  • sudo apt update && sudo apt upgrade ; sudo apt autoremove ; sudo apt autoclean

(Those last two are not strictly necessary but are a good practice to use.  If too much time passes between any of these sudo commands you will be asked to enter your password again.)

Install the g++ compiler:

(This is not required if you are just adding bash to Windows.  It’s an open source C++ compiler.)

  • sudo apt install g++
    • (answer y)

The final piece of this puzzle is the (optional but pleasant enough) VSCode (free community) version of Visual Studio.  You can get that for Windows, Mac, and Linux directly from this site.

Remember to have fun!

Share

4 thoughts on “So You Wanna Do C++ Programming on Windows

Leave a Reply to JamesIsIn Cancel reply

Your email address will not be published. Required fields are marked *