Contact: Nasseef Abukamail (abukamai@ohio.edu)
Welcome to Ohio University EECS. This guide covers the installation of the tools needed for computer science (C++ compiler, C++ debugger, WSL environment, Git, VS Code customization). Please keep in mind that all the tools are also available on our lab machines (Stocker 307A). The lab is open all day and can be accessed remotely. You will also be using Git/GitHub for source/version control.
Important: In order to be able to use your own computer to do the projects you need to install the following:
- C/C++ compiler like GNU C++
- Git tools
- A text editor such as VSCode
Installation instructions are outlined below.
- Ohio University, EECS Development Tools
-
Mac: Start the terminal program (Search forTerminal). Install theCommand Line Toolsusing the commandxcode-select --install. This will also installgit. Alternatively, you can install Xcode and install theCommand Line Toolsafter you run it the first time. -
Linux: Should already come with GNU g++ preinstalled. -
Windows:-
Install Windows Subsystem for Linux (Recommended)
This will give you a
bashterminal closer to what Mac and Linux has. If you go through the instructions listed there you can use the same instructions/commands as Linux/Mac that are shown in the rest of this readme file.
-
You need a good programming editor (DO NOT USE WINDOWS Notepad). I recommend Visual Studio Code. It is free and highly customizable. See below for other editors.
- Visual Studio Code (Recommended)
- Atom Editor
- Emacs
- Vim
- nano
- and many others ....
The debugger is configured for every project separately. You must open the project folder in order to use it.
The debugger depends on what executable file you set up in the previous step. Make sure you open the folder (not the program) where your program resides. You need to do these steps for every project you want to debug.
- Install the extension
CodeLLDB - Click on the debug icon on the left
- Click on
Run and Debug - Seclect `C++ (GDB/LLDB)
- Select
lldb - Build and debug active file - Edit the file
launch.jsoninside the.vscodedirectory and make the following changes:
"configurations": [
{
"name": "launch",
"type": "lldb",
"request": "launch",
"program": "${fileDirname}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "C/C++: clang++ build active file"
}Input interaction will be done in the terminal window within VScode.
- Edit the
tasks.jsonfile inside the.vscodedirectory and change theargssection to the following:"args": [ "-g", "${file}", "-o", "${fileDirname}/a.out" ],
-
Make sure you installed g++ and the debugger tools when you installed wsl https://github.com/nasseef/cs/blob/main/docs/Windows-WSL.md#tools
-
Open a WSL terminal
- Open PowerShell
- Type
wsl
-
Navigate to the project directory (it helps to create a symbolic link to the directory where you stored all your projects). Instructions on how to create a symbolic link can be found here: https://github.com/nasseef/cs/blob/main/docs/Windows-WSL.md#accessing-your-windows-files
-
Start VS Code from the project directory
-
Example (Assuming your project directory is called
project1):cd project1 code .
-
Open the project file
.ccor.cppfile -
Click on the debug icon on the left
-
Click on
Run and Debug -
Seclect
C/C++: g++ build and debug active file
This setup will use your file name as an executable (without the extension). If you want to use a.out as your executable, change ${fileBasenameNoExtension} to a.out in the file .vscode\task.json.
From this point on, you can click on the green arrow to start debugging. Make sure you set a break point. To set a break point inside your code, click to the left of the line number. A red circle should appear.
Note: you must open the project folder to debug your project. The above steps must be repeated for every project.
- C/C++ extension from Microsoft (Required)
- Code Runner (optional)
- Code Spell Checker (optional)
- Open
Preferencesand click onSettings - Find the entry called
Run Code Configuration(Available if you installedCode Runnerextension) - Enable the options:
Run in TerminalSave All Files Before RunSave File Before Run
-
Go to the Settings menu
-
Search for
Code-Runner: Executor Mapand click onEdit in Settings.json -
To be able to compile and run your program using the
Run Codeicon or the shortcutCtrl-Alt N, add the following lines right after the opening brace{inSettings.jsonand save it."code-runner.executorMap": { "c": "cd $dir && gcc -Wall $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", "cpp": "cd $dir && g++ -Wall -std=c++11 -g $fileName && ./a.out" },
On Windows use
./a.exeinstead of./a.out.-goption is needed to use a debugger such asgdborlldb.
You can configure VS Code to automatically save your file. Several options are available:
- Open the
Settingsmenu option - Search for
Auto Save - Select the desired option from the drop-down menu
VSCode already has built-in snippets such as a for loop, class, etc. However, you can create your own. Open User Snippets under Preferences. If you are editing a C++ file then the file cpp.json should open automatically. Otherwise, you may have to select it. Here is a sample of snippets that I use cpp-snippets.json.
We will be using Git/GitHub for version/source control (track changes to code). Here are some excellent tutorials that introduce the concepts and shows the most important commands you need to learn.
https://www.youtube.com/watch?v=MJUJ4wbFm_A
https://www.youtube.com/watch?v=uR6G2v_WsRA
Note: Git might already be installed on your Mac or Linux machines.
-
Create a GitHub account here GitHub
-
Generate a Personal Access Token (PAT) to be able to use GitHub remotely Personal Access Token
Here are some Linux commands and instructions to access our system remotely.
Linux Commands and Remote Access
Occasionally you need to transfer your files from your machine to our Ubuntu system and vice versa. In order to do this you need to use an SFTP (Secure File Transfer Protocol) client. Here are few SFTP clients:
It is very important to follow a good/standard coding style. Refer to this document when writing code. Coding Style