# Setup Environment
## Install Winodws Subsystem Linux
- `wsl --install -d ubuntu`
** if error **
- make sure hyper-v is enabled in windows feature (use windows search: `turn windows features on or off`)
- make sure virtualization is enabled in bios (Go to your computer bios)
** if older version of windows **
- Follow instructions on [Official Guide](https://learn.microsoft.com/en-us/windows/wsl/install)
- Once installed, you will notice a linux icon on your windows explorer 
- That is where the linux system is mounted, you can access file from there like a normal linux system
- to open a terminal of wsl, just open terminal and run `wsl`
- update and upgrade, then apt install `build-essential` for gcc and `manpages-dev` for man page.
## Connect vscode to WSL
- install vscode
- Install `Remote Development` package [Link](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack)
- Go to your ubuntu root mouting point: `\\wsl.localhost\Ubuntu\`
- find your folder you want as working environment, I use `/home/shane/c`
- Now you have a folder for your sorce, go to vscode, click on green button on left bottom corner, select `new wsl window`
- On vscode's explorer, select `open folder`, finally find the folder you just created
- now you can edit and run code as if you are on linux
### GDB, Valgrind
- Compile: `gcc -o <outfile> -g -std=c11 -Wall <source.c>`
- `-g` is for gdb
- `-Wall` is for valgrind
- [GDB dashboard](https://github.com/cyrus-and/gdb-dashboard)
- `break`, `step`, `next`, `continue`
- `print`
- More [cheatsheet](https://darkdust.net/files/GDB%20Cheat%20Sheet.pdf)
### Valgrind
- `valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./a.out`
-