MCS273 Introduction to C++ Programming (January 2013)

Getting Started


The purpose of this lab is to familiarize you with our computer facilities. You will also learn how to use the Integrated Development Environment (IDE) Eclipse (if you don't already), which you will be using for your programming in this course.

Eclipse is one of the most widely-used Integrated development IDEs in the industry. Eclipse has many features that help you edit, develop, test, and debug your programs. The purpose of this project is to give you a first glimpse at some of those features. In particular, you will be doing some variations of the Hello World program described in chapter 1 of our textbook. You do not need to hand in anything from this project, but there will be several check-offs, which are described below.


The classroom we will be using for the lab session (Olin 326) consists of 16 Mac Minis which are part of the campus-wide computer network.

There is a printer in the small room adjoining the classroom/lab. Its name is mcslab, so if you need to select a printer to print to, that is the one you should use when in the third-floor Olin computer labs.

Each Gustavus student has been given a computer account; this lab assumes that you already have read your account letter and changed your password. If not, and you need help with this, let one of us know. It does not matter which workstation you log into; you will have access to all your files on all computers, since they are stored on a central file server.

The following instructions assume some familiarity with such terms as single-click, double-click, and drag, which refer to the use of the mouse (the small doohickey next to the keyboard). If you don't understand something or if the instructions seem impenetrable, don't worry. These are examples of things better shown than described in words. Ask me to explain it to you. Also, feel free to talk with your fellow students. Computers are unfortunately fraught with many arcane terms, and defining them all would unduly clutter these handouts. Fortunately, if you are not shy about asking someone when you have a question, you should get the hang of it fairly quickly.

Special instructions for check-off labs

A large number of the labs (including this one) are so-called check-off labs. By this we mean that you need to show that you have finished specific tasks, which will demonstrate to us a basic understanding of the material covered in the lab. When you have finished one of the designated tasks, you should show me so that I can check you off on the given task.

Check-offs are worth one point each, and will be indicated in bold face in the labs.

Log in and use a Browser (1 point)

  1. Login using your Gustavus account and launch your favorite browser.

    We do not include instructions for these task because we figure that most of you already know how to do this. Furthermore, you can't even be reading this unless you are using a web browser such as Firefox, so these are basic boot-up tasks. We will briefly describe how to do this in the first class, and will help anyone who needs help during the first lab.

  2. Locate the Gustavus Adolphus College homepage by entering  in the Location box and pressing Enter. Since you may not want to remember this address for next time, select "Add Bookmark" under the Bookmarks menu. Next time you want to find the Gustavus homepage, select "Gustavus Adolphus College" under the Bookmark menu.

  3. My personal homepages are located at
    The course home page is located at
    You may wish to bookmark these as well.

  4. Check-off: Show me that you have located the course homepage and added it to your bookmarks. (Feel free to leave your browser open, continue work, and get checked off for this task and the next at the same time.)

The directory structure and Terminal (1 point)

Mac Minis on campus share a tree-structured file system. This means that the files on the computers are located in directories, which may themselves include files and subdirectories, which may contain files and other subdirectories, ....

When your account was created, you were given a home directory in which you can store and create files and subdirectories. This home directory resides on a file server maintained by the Gustavus Technology Services (which is located on the first floor of Olin Hall). Since your home directory is automatically loaded onto the computers, it really doesn't matter which specific computer you use. Whichever computer you use, you will have access to the files you created in your previous sessions.

For this course, I recommend you learn how to navigate the directory structure using a Terminal window, which is less system dependent and graphically based than other methods. Following are some tasks which will help you learn how to view and manipulate the directory structure using a Terminal window on Mac OS X.

  1. Open up a Terminal window.

    Terminal is a program that allows you to issue commands to the computer's operating system. Unfortunately, these commands are often somewhat arcane and difficult to remember. Fortunately, there aren't many commands that you need to remember.

    The easiest way to launch a shell is through Applications on Mac OS X. Get the list of applications by single-clicking on Applications on the Dock. Scroll down until you see Utilities and single-click on it. You will find Terminal here.

    Single-click on Terminal and a window will pop up, and you will be presented with a command line prompt from which you can issue commands. How it looks will vary from person to person, but will probably end with the % or > character.

  2. Find out your present work directory.

    As described before, each computer user at Gustavus has a home directory that is stored on the central file server. When you start up a shell, the present work directory is your home directory. To see what that is, type pwd. (You must press the "Enter" key to actually issue the command.) Do so. Your home directory should end with your username.

  3. View your home directory.

    You can view the present work directory by entering the command ls. This will list all files and directories in the present work directory.

    To get a more informative listing, type ls -l. This gives more information about the files and directories.

  4. Add some sub-directories (also known as folders) to your home directory.

    To add a directory called mcs273 into your home directory, type mkdir mcs273. Do so, and then type ls -l to see the newly created sub-directory.

  5. Check-off: Move to the mcs273 subdirectory and do a pwd to show that you are there and a directory listing to show that it is currently empty.

    You can move to mcs273 by typing cd mcs273 (think of cd as Change Directory). Do so.

    Typing cd .. will cause you to move up one level in the file system; typing cd will take you to your home directory.

Eclipse for C++ (1 point)

For this part, I strongly recommend that you work in pairs, with at least member of the pair having experience with Eclipse, hopefully in MCS 178, where we use Eclipse to program in Java. Many of the skills there are easily transferable to Eclipse for C++, which I will hereafter (ambiguously) refer to as Eclipse.

  1. Launch Eclipse.

    You will find this in the application folder under Eclipse for C++. Be sure you use that one. After a few seconds, it will ask you to select a workspace, offering you some default option. I recommend that you create one called Workspace in your mcs273, though it's up to you. Be sure that it is somewhere under your home directory, so that you have access to it from other computers.

  2. Do the "Create a Makefile project" tutorial.

    You can do this by clicking on the "Tutorials" icon in the Welcome screen, and then click on "C/C++ Development" link. This will take you to a web browser, where you should be able to see a "Create a Makefile project" link. Follow the instructions there. Warning: when you do the debugging, a window will pop up which will ask you to log in. You should log in with the name "gustavus" and password "adolphus", which will then allow you to do the debugging.

    You should be able to do the building, running, and cleaning both in Eclipse and in the Terminal, and you should be able to do the debugging in Eclipse.

  3. Check-off: I want each person (not just each group) to demonstrate that they can do the tasks above.


If you find you have time on your hands, I strongly recommend that you create a new makefile project called "Chapter02" and then populate it with the five programs in chapter 2, which you can easily get at the "Textbook Code" link at the side of the course web pages. You will have to figure out how to extend the makefile to deal with all of the source files.

Finally, I encourage you to download and set up Eclipse for C++ on you computer(s). I will be doing everything on the Macs, but it shouldn't be to hard to set it up on Windows or Linux.