Introduction to Programming
Read This First
-
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.
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.
-
-
If you have problems downloading it, see “Troubleshooting” item 1 below.
Next you can start actually importing and running the VM.
-
Open the Oracle VirtualBox program.
-
In the File menu, click “Import Appliance”.
-
Select the ova file you downloaded and hit “Next.”
-
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.
-
The Appliance Settings should be okay by default. Hit “Import.” This will take between 2 and 15 minutes typically.
-
Select the VM and press Start (see picture, right).
-
A new window should appear with the VM booting inside of it. That will take about a minute, depending on your machine
-
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.