-
You'll need Windows 10, build number 15042 or greater to use WSL
You can check your version by going to Settings -> System -> About.
-
Enable Developer Mode:
Start Menu → Settings → Updates & Security → For developers → and then check "Developer Mode".
-
Turn on "Windows Subsystem for Linux":
Start Menu → Settings → Search for "Turn Windows features on or off".
From that menu, check the box next to "Windows Subsystem for Linux (Beta)"
-
You'll probably need to reboot your computer.
-
Launch bash:
Hit windows key, search for "bash", and select "bash" (before installation is complete) or
"Bash on Ubuntu on Windows" (after installation is complete).
This should launch a bash.exe terminal.
The first time you open the bash WSL terminal, it will ask to
install Ubuntu on Windows. Press 'y' and enter to continue. Then
choose a username & password.
-
Install Ubuntu updates:
(Type these commands into your bash terminal.)
sudo apt-get update
sudo apt-get dist-upgrade
-
Install the necessary packages for this course:
sudo apt-get install g++ clang gdb zip valgrind
sudo apt-get install gcc-multilib g++-multilib
And press 'y' to continue.
Ensure that we can properly terminate a runaway WSL program:
(In case Ctrl-c does not work for you.)
NOTE: Do not attempt to edit WSL system files from Windows. The
permissions and filesystem will get messed up and you'll need to
reinstall everything to recover.
From the WSL bash terminal (using vi to edit the file):
vi ~/.bashrc
Press 'G' to go to the end of file. Press 'A' to append to the end of the line.
Press enter twice. Then type:
stty intr \
Then Ctrl-v, Ctrl-k. And the last line of the file should now look like this:
stty intr \^K
Then press escape, then press ':wq' and enter to save the file.
To have the new command take effect, run:
source ~/.bashrc
Now if you want to quit a running program, press Ctrl-k.
(Ctrl-c might work for you too.)
Install Dr. Memory for WSL:
Follow these instructions...
-
Install a good code editor on Windows.
If you don't already have a favorite, we recomend
Sublime Text.
-
Create a new directory for your work for this course on Windows.
Save the sample files to this directory.
NOTE: It's easier if you avoid spaces or other non-alphanumeric
characters (underscore is fine) in your file & directory
names.
-
In your WSL bash terminal, go to your directory for the
course.
Windows paths are available in WSL from
the /mnt/ mount point.
For example, if you saved the file
here:
C:\Users\myusername\Documents\DataStructures\temperature.cpp
cd /mnt/c/Users/myusername/Documents/DataStructures/
ls
And you should see your file.
NOTE: If you have spaces in your directory or file names, you'll need
to escape them with a backslash. E.g., Data\ Structures.
Now compile the file:
clang++ -o temperature.out temperature.cpp
And then run it:
./temperature.out
Or to test it through the memory debugger:
drmemory -- ./temperature.out
Or:
valgrind ./temperature.out
To disable the tab-complete bell in WSL bash terminal (it quickly gets annoying):
NOTE: Do not attempt to edit WSL system files from Windows. The
permissions and filesystem will get messed up and you'll need to
reinstall everything to recover.
From the WSL bash terminal (using vi to edit the file):
sudo vi /etc/inputrc
Scroll down to the line:
# set bell-style none
press 'x' twice to uncomment that line:
set bell-style none
press ':wq' and enter to save the file.
You'll need to close and restart your bash terminal for it to take effect.
-
Now, Test Your Installation.
-
If you have trouble with Valgrind on WSL, you may need to follow these instructions:
http://www.albertgao.xyz/2016/09/28/how-to-use-valgrind-on-windows/