Homework 0: Welcome To CS 174 / Software Test (12 Points)
Chris Tralie
Learning Objectives
- Practice basic terminal commands and folder navigation
- Practice compiling and running programs in the terminal
Description / Overview
We're doing some serious systems programming in the class, and I also want to have fun assignments that deal with multimedia data (images, music, videos, animations). Because of this, the process to setup a software environment for this class is more involved than usual. To make sure everyone is setup properly, I have devised a series of tests to verify that everything we need is working. If you get stuck or something unexpected happens at any point while following the instructions below, you should immediately post on Discord. We'll work through it there together (I'm giving students Mac and Windows labels on our channel to help us coordinate that)
First, follow the software installation instructions for Windows or Mac OS, depending on your computer. They may take a while, but you will be rewarded 😅 (with points on this assignment and with the inherent satisfaction of having a slick software setup). Once you're finished and everything is in place, create a designated directory for everything CS 174 related, open your terminal, and use the cd
command to change into this designated directory (alternatively, you can create the directory in the terminal using mkdir
command). Then, to obtain the test software I've created, type
This should create a folder called HW0_Warmup
in your current directory. Change into this folder and type ls
You should see these folders/files
If that all worked, proceed to the following tests. Take note of what you see, and submit the results to this link on Canvas
Audio Test (3 Points)
Change into the sound
directory
then type
Now run the generated program
If everything is working properly, this should generate a file called mysterysound.wav
. Open this file, and take note on canvas of what number is spoken
Canvas Test (3 Points)
Now go back up a directory and into the directory canvas
then compile the program there by typing
Now run the generated program
If everything is working properly, this should generate an image called mystery.png
. Open this file, and take note on canvas of what shape you see
CMake / OpenGL / Live Animation Test (3 Points)
Now go back up a directory and into the directory tinygl-cpp
(this library is courtesy of Aline Normoyle right down the street at Bryn Mawr College). The compilation process for the program here is slightly more involved because we'll be using something called cmake. Once you're in the directory tinygl-cpp
, create a new directory called build
, change into it, and use the cmake
command to generate a makefile for your system (we'll talk more about makefiles in class)
Now you can build the program by typing the command make
Now run the generated program mysteryletter
If everything is working properly, this should pop up with a window with a letter bouncing up and down. Take note of this letter, and write on Canvas what it is.
NOTE: Windows users should be sure that they are vcXsrv in the background before executing mysteryletter
Valgrind Test (3 Points)
One last test to go! We're going to test something called a memory leak, which is when we don't take care to cleanup dynamic memory that we request during the run of our program. This takes place automatically in Java using something called a garbage collector, but we have to handle it manually in C and C++. It's very common to forget to clean things up, but this can cause us to run out of memory, as well as other strange errors. Thankfully, there are tools to check for memory leaks, and we'll be using one such powerful tool called valgrind in this course (or, alternatively, clang's memory leak sanitizer).
Change back to the root of HW0_Warmup
. Then, if valgrind installed properly for you (which it should have on Windows or Mac OS Catalina), do the following:
Valgrind Directions
Now type
If you had to do the alternative installation, then use the following directions
Clang++ Memory Sanitizer
Now type
In both cases, take note of how many bytes of memory were "lost" or "leaked," and indicate this number on canvas. Also, indicate whether you used valgrind or clang++'s memory sanitizer.