Skip to content

nasseef/cs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Ohio University, EECS Development Tools

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.


Installing C/C++ compiler & Windows Sybsystem for Linux (WSL)


  • Mac: Start the terminal program (Search for Terminal). Install the Command Line Tools using the command xcode-select --install. This will also install git. Alternatively, you can install Xcode and install the Command Line Tools after 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 bash terminal 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.

Recommended Editors


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.

Configure the Debugger

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.

Mac Setup
  • 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.json inside the .vscode directory 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.json file inside the .vscode directory and change the args section to the following:
    "args": [
                  "-g",
                  "${file}",
                  "-o",
                  "${fileDirname}/a.out"
            ],
Running The Debugger in WSL

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.

VS Code Customization


Extensions

  • C/C++ extension from Microsoft (Required)
  • Code Runner (optional)
  • Code Spell Checker (optional)

Configure the compiler to run in a terminal

  • Open Preferences and click on Settings
  • Find the entry called Run Code Configuration (Available if you installed Code Runner extension)
  • Enable the options:
    • Run in Terminal
    • Save All Files Before Run
    • Save File Before Run

Configure Code Runner to use -Wall -std=c++11 -g

  • Go to the Settings menu

  • Search for Code-Runner: Executor Map and click on Edit in Settings.json

  • To be able to compile and run your program using the Run Code icon or the shortcut Ctrl-Alt N, add the following lines right after the opening brace { in Settings.json and 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.exe instead of ./a.out. -g option is needed to use a debugger such as gdb or lldb.

Auto Save

You can configure VS Code to automatically save your file. Several options are available:

  • Open the Settings menu option
  • Search for Auto Save
  • Select the desired option from the drop-down menu

Helpfull user snippets

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.

Git/GitHub


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

Git Installation

https://git-scm.com/download/

Note: Git might already be installed on your Mac or Linux machines.

Create a GitHub account

Linux Commands and Remote Login/File Transfer


Here are some Linux commands and instructions to access our system remotely.

Linux Commands and Remote Access

SFTP Client


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:

Coding Style


It is very important to follow a good/standard coding style. Refer to this document when writing code. Coding Style

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published