# CSCI 103 Summer 2018: Introduction to Programming

## Installing the Virtual Machine

If you are having trouble installing the Virtual Machine you should scroll down to the Other Options section

• Never install updates on the Linux VM. If it asks you, just say no!
• A version of the VM is installed on the SAL PC's (under the Windows OS)...if your laptop breaks, use those PCs. See below for details
• If you can't seem to connect to the Internet on your VM but your laptop OS can, simply reboot the VM (not your laptop). Most of the time this will allow your VM to reconnect.
• We will grade your assignments on the VM. If you want to use your own compiler/environment like Visual Studio, etc. you should ALWAYS bring your code over and test it on the VM before submission. If your code does not compile on the VM, we will not try to fix it and you may get a 0. Consider yourself officially warned!
• If VirtualBox cannot start your VM after it is imported you may need to enable virtualization in your BIOS which can be accessed on Win8 or 10 by following these steps. Look for the setting called "virtualization", "VT-x" or "AMD-V" and enable them
• To be able to resize the Virtualbox window and have the display resize appropriately you may have to install the 'Guest Additions' on the VM. See below for details.

### Installation

Before the end of the first week, you should attempt to install the course Virtual Machine (VM) on your laptop. Course staff will be able to help you in case of any problems. Post questions/problems on Piazza first so we get a good report of problems encountered, though complex issues may require a visit to office hours.

In order to get started running the course software, there are two things to download.

1. Install the Virtual Machine (VM) hosting software, Oracle VirtualBox. It's available at

follow the link for whatever operating system you own (Windows or OS X). Then, install the Virtualbox software package using all the default options.

Next, download the course VM image, an "ova" file called StudentVM_Spring2018. It's a very large file, between 2 and 3 gigabytes. It can take a long time; consider downloading from a wired connection, or overnight. You can access it through this link:

http://bytes.usc.edu/files/cs103/install

Next you can start actually importing and running the VM.

1. Open the Oracle VirtualBox program.
2. In the File menu, click "Import Appliance".
• If the ova file download was incorrect or corrupt, you would encounter an error. Check that its size is around 3 gigabytes and see "Troubleshooting" item 1 below.
4. The Appliance Settings should be okay by default. Hit "Import." This will take between 2 and 15 minutes typically.
5. Select the VM and press Start (see picture, right).
6. A new window should appear with the VM booting inside of it. That will take about a minute, depending on your machine.
7. The VM will auto login. If you ever need to know it, the password for the student user is 'developer' (no quotes).

Congratulations! Your virtual machine is successfully running the Ubuntu operating system (a kind of Linux). Here are few things to try out.

• If you have a laptop with less than 4GB of RAM — this includes some AirBooks — see Memory Settings below.
• Open a browser and see if you can reach the internet. If it doesn't work, see Troubleshooting item 2 below. A working internet connection will make many things easier including backup and assignment submission.
• It's a good idea to keep your course files backed up. You can use Dropbox to do so: it is compatible with Ubuntu. Click the Dropbox icon on the left and sign up or log in to your existing account.
• If you do this, you should keep all your work in the directory
/home/student/Dropbox (also known as ~/Dropbox)
instead of /home/student (also known as ~)
The first lab will explain a little bit more about directories.
• Click the Terminal icon on the left-hand side. It'll be used extensively throughout the course.
• Type in ls to list the contents of your default folder ( /home/student). You should see "Desktop" and maybe "Dropbox"
• Type in ls /usr/games to try listing the contents of a specific folder.
• You could run one of those games by typing  /usr/games/somegamename
• Try compiling and running a tiny program.
• At the Terminal, enter gedit four.cpp & which will open a text editor called gedit.
• Copy and paste (see Guest Additions below) or type in:
#include <iostream>
using namespace std;
int main() { cout << 2+2 << endl; }

• Save your work and quit gedit.
• At the Terminal, enter compile four
• At the Terminal, enter ./four and you should see the number 4 printed.

Fine-Tuning

• Don't try to apply any updates or upgrades to the system. You can try learning about apt-get on your own to install new packages, though you do so at your own risk.
• You should enable the “Guest Additions” to be able to resize the window, use copy/paste and other features. Click the Devices Menu and Install Guest Additions. Press "Run" at the prompt. You may have to enter your password (developer) or hit "Enter" once or twice. When it says "Hit Enter to close the window," restart your VM and everything should work.
• Memory Settings. Laptops with under 4 gigabytes of memory (RAM) may have problems. If you want to check this, follow these instructions.
• While the VM is shut down, go to VirtualBox and click the Settings  icon.
• Go to "System" tab (2nd in the left menu).
• Look at the Base Memory on the top of the right tab. Is the slider's current position in the green zone or the red zone? If it's in the green zone you have nothing to do.
• Being in the red zone is bad. It occurs on older or low-memory machines. This should raise the warning icon  at the bottom. You can click on it for more info (see right). It will probably say to keep the VM memory not so large compare to the real machine's memory. Slide it down to the top of the green zone (hopefully at least 2 GB) and eliminate the warning.
• You can enable 2 cores if you want things to be a bit faster, but this is optional, and may not work if virtualization is not enabled (see Troubleshooting item 3).

### Troubleshooting

1. If the "ova" file did not download with the right size,
• You can get around this using an FTP client, which will support resuming stopped downloads. For example you can download the FileZilla FTP client from
• Once installed, connect to host "bytes.usc.edu" and inside the "cs103" folder, inside its "install" subfolder, download the ova file.
2. If your internet connection in the VM is not working,
• check that your actual machine has a connection!
• before trying the next step, simply reboot your VM and see if it can connect. 95% of the time this does the trick
• if the above has not worked: go to the Devices menu of VirtualBox, and click Network/Connect Network Adapter; then go back into that menu and Connect Network Adapter again; wait a few seconds and the problem will often resolve
• otherwise, seek help from course staff
3. If VirtualBox cannot start your VM after it is imported you may need to enable virtualization in your BIOS which can be accessed on Win8 or 10 through these steps. Look for the setting called "virtualization", "VT-x" or "AMD-V" and enable them.
• For about 1% of students, the BIOS has no such option. Please bring your laptop to course staff for them to double-check this. We will issue you a different version of the VM.

For any other problems, see course staff.

### Other Options

The virtual machine image is installed on all the Windows PC's in the engineering computing center (SAL). Thus, if you absolutely can't get the VM working on your laptop, you can use one of these computers. Follow the directions below:

1. Boot to Windows (not Mac)
2. Find the VirtualBox icon on the desktop and start the application (not Mac)
3. Many of these machines already have the student-vm imported and ready to run so that you can just start the VM and use it
4. If the student-vm is not already imported you may do so by clicking File..Import Appliance. Then click the browse folder icon to go find the .ova file. Browse to
Computer\C:\CS VM\student-vm.ova

Then click import.

5. Once the appliance is imported you can start it and use it
6. Your files will not be saved from one session to the next, so please copy your files to your USB drive, Dropbox, etc.

### FAQ

Q: Do we need to use the VM? Can I use my favorite other C++ compiler?

A: Yes and no. We will only grade your submission using the VM, thus we recommend using the VM for beginners (which is the majority of the class). This ensures that you use the exact same version as the course staff and graders. Warnings if you don't use the VM: The compiler errors or warnings you get on your own machine/compiler might not match ours. We will do our best to make sure you get lots of feedback when you submit code for assignments, but be aware that you might need to budget extra time before deadlines to fix these incompatibilities. You will have to figure out how to run a debugger and the valgrind tool on your own.

Q: Can I use a different text editor?

A: You can. However, sublime (subl at the command line) is a very good editor w/ syntax highlighting etc. So is gedit (gedit at the command line) Both are pinned to your launch bar in the VM. Warnings if you use a different editor: Configure it to use only space characters and not tab characters for indentation, this will make it easier for us to understand your indentation when we print your code for grading.