Summary for the impatient

If you are daunted by the length of this lab, please be assured it is just a bunch of details that we need to take care of to get started. If you want the short version, you need to do the following before your first, actual lab session, all of which you can do from your laptop if you wish. You can get used to the lab machine environment later if you don't have the time.

  • Activate your EGR account.
  • Start mobaXTerm and make sure it runs
  • Activate Mimir so you can turn in your work
  • Do the simple assignments and make sure you can do your work.

    Note we mark parts of the lab to show to your TA with a . Since you are doing the work online, you cannot show your work but you can check yourself at these points.

    Setup and First C++ Program (Lab 00)

    The Lab

    All of your laboratory sessions take place in the Engineering Building, room 3345. However, after lab you may use any of the public computers in the Engineering Bldg as they have exactly the same configuration that will be described below.

    If you are a strictly online student and not required to attend a lab, you might still want to come in and try out these machines as you might use them during the course of the semester.

    The Machines

    There are 24 workstations in 3345 for the laboratory sessions.

    These are two monitors of Windows 10 machines. Though these are Windows 10 machines you will soon see how we will be using these to learn Linux!

    Part 1: First Login

    As of Fall 2017, the Department of Engineering and Computing Services (DECS) of the Engineering College will be managing all the public laboratory machines in the College. This is good news as it will give you access to more machines throughout the college.
    • If you have never logged in to a EGR machine, never had a login, this section is for you.
    • If you have a login but forgot your password, you are out of luck and will have to visit EB 1325. Bring your picture ID!
    • If you have a working login, move on to Part 2.

    First Login from the Labs

    This is the screen you would typically start from for the EGR Windows 10 machines.

    Simultaneously hold down the three keys Ctrl-Alt-Delete and you will get the login screen

    Type your MSU netid as your user name. As you password type your pid, starting with a capital A and ending with the @ sign.

    Activate Account, online or in labs

    If you are in a lab, you'll be taken to your DECS Myaccount page

    If you want to activate from a web browser, you can visit the link from anywhere.

    Pick "Activate Account" on the left and follow the directions. Make sure to select the button on the bottom that says you agree to following the EGR Acceptable Use Policy.

    Since new accounts use your student PID for a password, accounts are vulnerable until this process is completed. At any point, you may receive an email reminding you of this.


    EGR requires a "strong" password. Your new password must have the following characteristics:

    • Be at least 8 characters long (or longer). As a side note, the most useful thing about making a password secure is its length!.
    • Must not include your NetID.
    • Contain at least 3 of the following classes of characters.
      • Digits (numbers)
      • Uppercase letter.
      • lowercase letter.
      • Punctuation character.

    How to change your password

    Your EGR "my account" page is the place you can use to change your password, but it does require that you know your present password.

    • Go to
    • Select Login (if it isn't already selected) and login with your present NetID and EGR password
    • Select from the list of elements on the left column for what you would like to do.


    If you cannot get it to work (try real hard) you can go to EB 1325. Bring your picture ID!

    Lastly, log back in with your new password.

    Part 2: Working with Unix

    We are going to be working with Unix over the course of the semester, and through Unix a C++ compiler and other tools. You have a choice about how you interact with Unix and the compiler, which we will cover below. You can use any or all of the choices, but during the regular laboratory sessions we will be using MobaXTerm.

    • MobaXTerm . You can MobaXTerm to login to a server which and get access to all the tools on the server, as well as a central location to store your files.
    • Mimir . The auto-grader/handin site we use is called mimir and provides a Unix IDE in a browser which can be used from anywhere.
    • Something Else . There are lots of ways to get a compiler and/or unix on your own machine.

    Part 2.1: Working with the Lab Machines

    You probably know enough about Windows 10 to do work, but here's a little refresher to get you going. Everything runs off the "Start" button, the flag at the lower left of the screen.

    When you click on start you get a scrollable list of all the programs you can run, such as a Mozilla Firefox browser.

    Part 3: MobaXTerm

    We will be using the application MobaXTerm as a terminal and X windows server for our exploration of Unix. We will use the terminal to log into the Engineering Linux servers, in particular the server reserved for us: (very easy to remember). The terminal will be our window into learning the Unix command prompt, but it will also allow us to display windows, such as editors, on our screens here.

    MobaXterm is already installed on the lab systems. If you want to download it to your local machine (Windows only, other solutions are needed for mac!!!!!) you can go to the link at

    Download MobaXterm

    Download the free one (no need for the "pro" edition). Either way, once it is installed you can find it on the start menu

    If you are using the lab machines you are presented with the following screen

    Notice that is already provided as a session to start. You can select that.

    If you are starting at home, you would see the following:

    We want to start an SSH session so select that. Hit OK. You are then presented with

    You can type in any server you have a login to, but we have reserved the server

    And again hit OK. Whichever way you get a terminal started, you will then be asked to login. Use your Engineering login name and password you set up in the previous part of the lab.

    And you are in

    What about being on a Mac

    No MobaXTerm for Macs, but you do have a builtin way to do the same thing with one extra piece of software. You need to download Xquartz at

    download Xquartz

    And then install as usual. You then need to open up a Terminal in Applications -> Utilities

    Then type the following. Pay attention to details: upper vs lower case matters. Use the login name you set up in the pages above

    ssh -X

    Xquartz should start automatically and the same ability to run on the server but show the window locally on your mac should be there for you to work with. The terminal is now connected to the server and you can use it as you would use it in MobaXterm in the labs.

    Where am I really

    This is a hard thing to get right so pay attention. When you login to a remote server like chuck, you are working on a server that is not in the lab, but in a machine room somewhere. Simultaneously, you are working on a lab machine right here in the room. Files stored on your local windows machine are not available on the server unless you take some special care

    There is a special directory that is made available to you when you log into a lab machine. It is the M directory and it is special because it looks like a local folder on the lab machine but it is actually a link to the files on the server, where you logged into using MobaXterm. When you save files you should always save to the M: directory so you can access those files from anywhere, including from your local laptop, when you log into the server.

    When you look at the drives on your windows machine, you can see that the name of the M drive should be the same as your login name (in this case punch). You should always save files to the M: drive. You can access them from anywhere and they get backed up!

    Working with External Data on your laptop

    I updated the FAQ to have more information on how to mount external network drives. Please see the this link

    Editing and Compiling

    For compiling, if you save to the M drive then you can compile using the directions found below . There is no real compiler on the local Windows machine unless you count Visual Studio, which can be problematic. Compiling on the servers is better, more like what you have to use with Mimir.

    For editing you can edit locally on your lab machine (or your laptop if you follo) as long as you save the files to the server directory. You can also use the editors on the server and have the server display the editor window on your local machine. MobaXterm is set up to allow that.

    For example, you can start the editor Visual Studio Code from the Windows start menu. This means you are doing your work on the local lab machine. When you save a file, save the file to your M: directory.

    You could also start VSC from the MobaXterm window by typing the command code , you get the same window but now you are running VSC on the server with the window being displayed locally. This is pretty convenient! It means that, from home, you can open the terminal and have access to your files and the same editor. Very nice. We recommend this approach


    Editors are like religion: most people have one but don't like what anyone else has chosen. You will have the opportunity to pick the editor of your choice as you go along. The image below lists the 4 that are available on chuck: Visual Studio Code(VSC), emacs, gedit, vim. Some basic info:

    • Visual Studio Code (VSC) is a modern, programmer's editor. It is very flexible, has many options, and can be used cross platform. If you want to be a programmer, this is a good one to learn so we'll start with this one.
    • Emacs is a very old, very configurable, editor. The joke is that emacs is an operating system disguised as an editor. This is what I use but I would not start here.
    • gedit is a straight-forward, editor. It is not very configurable but does a good job at just being an editor. If all else fails I would pick gedit.
    • Vi/Vim is also very old, but comes as standard in many linux OS as a default editor. I wouldn't start here, but learning vi is something every programmer should do.
    There is a lot of information on how to setup VSC. One of our own students, a previous TA, Matt Pasco has written a page on how to setup VSC on your local computer. The setup allows you to compile and debug from VSC, something we appear not to be able to do on the lab machines. Take a look here .

    Part 4: Working with C++

    Section 4.1 About C++

    From Wikipedia:

    C++ is a general-purpose programming language. It has imperative, object-oriented and generic programming features, while also providing facilities for low-level memory manipulation.

    Languages come in various "levels", from "low" meaning very close to the CPU they might run on (assembler for example) to high, such as Python which abstracts much of that away. C++ is a kind of intermediate language, without all the help you might get from a Python but higher then an assembler.

    It is important to remember the C++ is a compiled language. That means that you must pass your code through another piece of software called a compiler that translates your C++ into nearly machine-ready code. Note that Python has no requirement as there is always an interpreter available for running Python code.

    The greatest strength of C++ is its potential for creating fast executables and robust libraries. C and C++ provide great flexibility in controlling many of the underlying mechanism used by an executing program. A programmer can control low-level aspects of how data is stored, how information is passed and how memory is managed. When used wisely, this control can lead to a more streamlined result. This is the point of the class. You are in charge of how your code runs because you (the programmer) are responsible for most aspects of how your code runs. This is a double-edged sword as being responsible gives you more opportunities to screw up.

    One of the problems with C++ is that parts of the syntax have grown cryptic. More signifcantly, the fexibility given to a programmer for controlling low-level aspects comes with responsibility. Rather than one way to express something, there may be alternatives. An experienced and knowledgeable developer can use this flexibility to pick the best alternative and improve the result. Yet both novice and experienced programmers can easily choose the wrong alternative, leading to less-efficient, and possibly flawed, software. Be careful!

    Section 4.2 Doing it on your own

    The best by far way to do your work is either though a terminal or mimir as we have discussed.

    • MobaXTerm on Windows requires only the download of a single application which gives you access to a full unix environment for your everyday work from anywhere with an internet connection. The Mac requires only Xquartz. These are both good approaches.
    • mimir required only access to a web browser and the internet. While it does not provide a full unix environment, it does provide a unix terminal and a compiler, enough to do your work

    However, since you are CS students perhaps you would like to do this on your own computer. Good news, C++ is available for any platform and has been for decades. Bad news. Couple of bad news things:

    Bad News 1: Getting a compiler

    • For Linux, you already have it. Congratulations!
    • For Mac OSX, you don't have it by default. However, you can get it if you follow these directions . They show you how to install part of Xcode, a large application developed by Apple for development, as well as the command line tools for your Terminal application.
    • Windows, you don't have it, but two things:
      • You have available on the lab machines Visual Studio. You can try it out there if you like.
      • You can download for free a copy of through DECS. Go to this page and Login (bottom left) with your EGR name and password. You can then "Start Shopping". Select "Developer Tools" (column on the left) then download "Visual Studio Enterprise". Install it on your Windows laptop (Note there is a version of Visual Studio Code but it is just an editor, no compiler).
    • Windows 10 also has a new feature (not yet enabled on the lab machines) called Windows Subsystem for Linux (WSL). Windows 10 does not come with a Linux command line but WSL provides one that looks very much like an Ubuntu 16.04 Linux terminal. You can set it up and run your code there, as you would on mimir. More adventurous, but take a look here . It really is quite nice!

    Bad News 2

    It turns out that C++ compilers are software just like any other program. Thus depending on versions and vendors, C++ compilers can have slightly different behavior.

    The Rule of Compling No matter how you develop your code, the only compiler that matters is the on on Mimir where you will turn in your code. If it compiles and runs there, great. If not, then it is up to you to get it to compile there. Only Mimir Matters

    Section 4.3: Editing and Compiling Code

    The first program you run in a new language is the Hello World program. This program does nothing put print the words “Hello World”. It is a tradition because it does very little except focus on the mechanics of writing your first program and running it. Look at the wikibooks page Hello world for more than 200 programming language examples of hello world.

    In C++, Hello World is fairly easy, but clearly more work than something like Python! Pick an edtior and save the following

      #include <iostream>
      int main( ) {
         std::cout << "Hello World" << std::endl;

    You can copy and paste the code into your text file (name it "lab00.cpp").

    Next, the plain-text file needs to be compiled and executed. To compile with GNU's C++ compiler, type the following into the terminal:

    g++ -std=c++14 -Wall lab00.cpp

    g++ is the GNU C++ compiler. In the above line, we have added a flag -std=c++14 to ensure that the code is compiled using the newer C++14 standard (by default, most C++ compilers use the C++98 standard, which does not include all of the features/extensions that we will be using in this class). The -Wall is useful for finding errors. Although our "Hello World" program does not contain any C++14 extensions, it is a good idea to get into the habit of including this flag.

    By default, g++ will create an executable named a.out. If your compilation went correctly, you should see this newly created file in the current directory.

    Finall, to execute/run the program type:


    The ./ simply means look into the current directory when attempting to find the a.out program. If all has gone according to plan, running the program should result in "Hello World" being printed to the command line.

    Make sure you can run the Hello World program.

    Note that to build a program consisting of multiple files in a directory, we will enter:

    g++ -std=c++14 -Wall *.cpp

    This will compile all the files that make up the source code of your program.

    The typical workflow is something like:

    • edit your code files using your favorite editor, then save (File -> Save) your code with a .cpp suffix
    • In your command line terminal, enter, g++ -std=c++14 -Wall *.cpp .
    • If there errors (and there will be errors), read the error messags and re-edit your code. Repeat until it compiles
    • Once your code compiles, enter ./a.out in the terminal to run the compiled executable. and observe the ouput, hopefull the correct output

    You repeat the process of edit - compile - run until you get the result desired

    Section 4.4: Reading and Producing Data

    Most programs running on a UNIX system read their data from standard input, write any data they produce to standard output, and send error reports to standard error. By default, standard input is taken from your terminal's keyboard, and standard output and standard error are both sent to your terminal's screen. You can redirect any of these three to read input from a file, write output to a file, or send data directly from the output of one program to the input of another.

    To send the output of a program to a file, use the > (right angle bracket):

    ./a.out > outputfile

    The following example uses cat, which is a standard Unix utility that reads files sequentially, writing them to standard output (the name is derived from its function to concatenate files). To redirect standard output and standard error to a file, use the command sequence (note, the dollar sign ($) is a marker for the prompt, hinting that you should run the command after it, you never actually type the $):

    $ cat abcd >& errfile
    $ cat errfile
    cat: abcd: no such file or directory

    In this example, we redirected the error message "No such file or directory" to the file "errfile". Therefore, no error message appears on the terminal until we list the contents of "errfile" with another cat command.

    To take the input of a program from a file, use the < (left angle bracket):

    $ ./a.out < input.txt

    Again, a.out is the default name of output from g++, i.e. the executable of your program. If your program uses cin (the standard input stream, usually representing the keyboard), it takes its input directly from the terminal. However, you can place your input in a file and then send the file to a.out through standard input. The ability to read standard input from a file, rather than from the keyboard, is convenient.

    You may often wish to redirect both standard input and standard output in and out of your programs. For example, to input input.txt to your program and send the output to output.txt, do the following: $ ./a.out < input.txt > output.txt

    We'll be learning more about input and output, so hold on a bit for more detail.

    Section 5: Mimir and Projects

    For some labs, particular this first lab, and all projects, we will be using the Mimir Platform. Mimir provides a convienent way to write, test, and submit your code. The assignments will have an associated Mimir page, including this one. Follow the directions below to submit your Lab 00 assignment for automatic grading.

    Section 5.1: How to access Mimir

    First, Mimir is not free. It requies you to pay a $25 fee to join the course.. Update! The College of Engineering has agreed to pay the fee for Mimir. Thus it will cost you nothing to join!

    Mimir is required software . You have to join Mimir as it is the only way you can turn in your work for the course. In the long run I think you will appreciate the ability to test your code before you turn it in, as well as having a simple interface via web browser requiring no software.

    You access Mimir by logging in to D2L , our course management environment. Select this course's page "CSE 232 Intro to Programming II in C++, Spring 2019" . You should see the following

    In the Content Browser section, click on "CSE 232 Useful Links", then click on "Mimir login" (obviously we aren't in Spring 2018, but you get the idea)

    Once logged into Mimir, look for . From that page, you should see a link called "Lab00 - Hello World". Go to it. This is the Project Submission page. On this page, you have see the project's description, and any project submissions you have turned in.

    At the top right are three important buttons:

    • "Submit": this is the alternate method for submitting code (where you need to zip and upload your code).
    • "Download Starter Code": this gives you a zip file of the files we want you to edit.
    • "Open IDE": this opens Mimir's terminal and editor

    Click the "Open IDE" button to go to Mimir's IDE. It should open a separate tab that looks like this:

    Mimir Workspace and IDE

    You have three columns. On the left is a file browser. You should have a folder named "cse232 Spring 19" for this class. The second column is a file editor. The third column is a command line shell. The windows on the middle and right can be open and closed. They are used to view and edit files (middle) and type shell commands (right). Please close the window named "untitled". Then, using the file browser open the file inside Open cse232_spring_18 → lab00__hello_world → lab00 → hello_world.cpp. Use the little arrows at the left of each name to open the directory below Your tab should look like this:

    Note that you lost the two column mode you started with. You can move the terminal tab and editor windows tab. If you drag a tab far enough to the right it will re-establish the two columns. Drag it back to the left and get one column where you can switch which is the active tab. This gives you some flexibility in how you do your work.

    Lab 00

    Lab 00 consists of two (hopefully simple) tasks. Correcting a typo in the file "hello_world.cpp" and creating a new file called "academic_dishonesty.cpp".


    I tried to write a "hello_world.cpp" file to show you how easy it is, but I made a typo. Take a look at the "hello_world.cpp" file it should already be open, but it is located in a folder with the class' name -> lab00__hello_world -> lab00.

    Please correct my spelling of "Hello" then save the file.

    Then right-click the folder named "lab00_hello_world" (sure you you select this one), and select "Submit dir to Mimir", be sure to select the correct assignment as well.

    Now you can go to your submissions page (the other Mimir tab), and confirm that you are passing the tests regarding hello_world.cpp.


    The next part of the assignment involves making a new file called "academic_dishonesty.cpp".

    Right-click on the folder named "lab00" and create a new file named "academic_dishonesty.cpp". Make sure the name is exactly what is indicated.

    Copy the contents of hello_world.cpp into this new file.

    Submit the assignment again like we did before. You should pass all but the last test . We need to fix that.

    Modify the file academic_dishonesty.cpp to print out the following message exactly (instead of "Hello World").

        My name is Bill Punch. I read the syllabus and I understand the consequences of academic dishonesty.

    The file needs to have the exact message above, except the name Bill Punch should be changed to have your actual name instead (using only A-Z, a-z and space characters please). By submitting this assignment, you are confirming that you read the syllabus and understand the consequences of academic dishonesty.

    Submit the assignment and you should pass all the tests and be done with Lab00, Congratulations!

    Demonstrate to the TA that you are passing all tests.

    All the Projects and Pre-Labs for this class will be performed with Mimir, so it is important that you are familiar with it before starting Project 1.