CSCI 1200 Data Structures
Spring 2016

Home
  Contact Information
  Announcements
  Discussion Forum (LMS)

Syllabus
  Learning Outcomes
  Prerequistites
  iClickers in Lecture
  Course Grades

Calendar
  Lecture notes
  Lab materials
  Homework
  Test reviews

Weekly Schedule
  Office Hours
  Lab Times

Getting Help
  Tutoring
  Advice from TAs
  Advice from Students

Homework
  Due Date and Time
  Late Day Policy
  Compilers
  Homework Submission
  HW Grading Criteria

Collaboration Policy &
Academic Integrity

C++ Development
  Code Editors & IDEs
  OS Choices
  Installing Cygwin
  Memory Debugging
    Valgrind
    Dr. Memory

References
  Optional Textbooks
  Web Resources
  Misc. C++ Programming
    Command Line Args
    File I/O
    string → int/float

Downloading and Installing or Upgrading Cygwin

NOTE: Cygwin is available in both a 32-bit version and a 64-bit version. If you have a 64-bit operating system (most of us do!) then you may use either version of Cygwin for this course. CAUTION: If you start with one and accidentally use the other Cygwin installer, you will end up with 2 versions of Cygwin on your machine which is super confusing.

  1. If you have the RPI Mobile Computing Program Laptop with the provided software image, you may already have Cygwin installed, but we'll need to upgrade and add a few additional packages. First, let's find out whether you have the 32-bit or 64-bit version of Cygwin.

    Go to the start menu/search bar and search for "Cygwin". If you have a program named "Cygwin Terminal" you have 32-bit Cygwin. If it's named "Cygwin64 Terminal" you have 64-bit Cygwin. To confirm the version, click to launch the Cygwin terminal, and then type:

      file /bin/ls
    

    If the output includes PE32 and 80386 you have 32-bit Cygwin. If the output says PE32+ and x86-64 then you have 64-bit Cygwin.

  2. Go to http://cygwin.com/install.html and download the 32-bit setup-x86.exe OR the 64-bit version setup-x86_64.exe.

  3. Double click the setup file, click Next to enter the setup program. The "Install From Internet" box should be selected, then click Next.

    Your Root Directory should be C:\cygwin (or C:\cygwin64 for the 64-bit version) & the box to install for "All users" should be selected, then click Next.

    The Local Package Directory will be used to store packages downloaded from the internet. You may put this anywhere on your machine (the default is probably fine). Click Next.

    The "Direct Connection" box should be selected, click Next.

    Then, pick a mirror, any mirror, and then click Next again.

  4. There's a ton of info on this next page of packages to choose and such, just keep the "Curr" choice selected at the top right.

  5. You will need to install a number of extra packages for your work in this course:

    • First, type "zip" in the search box near the top of the installation window. Open up the "Archive" section, then locate the "zip" package. The description should be "zip: Info-ZIP compression utility" . Click on the word "Skip" on that line to indicate we want to install zip rather than skipping it. A version number should appear, like "1.2.3.4".

    • Next, type "g++" in the search box. Open up the "Devel" section, and click on "Skip" for "gcc-g++: GNU Compiler Connection (C++)" until the version number appears.

      Also, click on "Skip" for "mingw-gcc-g++: GNU Compiler Connection". (This is needed to run the Dr. Memory memory debugger.)

    • Then, type "gdb" in the search box. Open up the "Devel" section, and select "gdb: The GNU Debugger" for installation.

    • Then, type "clang" in the search box. Click "Skip" for "clang: C/C++/ObjC compiler frontend based on LLVM" until the version number appears.

  6. Then go ahead and hit Next. If a "Resolving Dependencies" window shows, make sure the "Select required packages" box is checked, hit Next again and take a coffee break. Your computer is going to download a plethora of packages, and then install them. It may tell you that you have to reboot after the install, if it does, do so. After updating an existing Cygwin installation, be sure to close & re-open any Cygwin terminals so you have the new packages.

  7. Click finish and pat yourself on the back, you've finished a complete Cygwin install.

Helpful edits to the Cygwin .bashrc file

NOTE: You'll need to close & reopen your Cygwin terminal after making the edits below.

  1. First, locate your .bashrc file for the current user. This is probably c:\Cygwin\home\YOUR_USERNAME\.bashrc (or just ~/.bashrc from the Cygwin shell). Make a copy of this file and put it somewhere safe before making the changes below, so you can undo in case anything goes wrong.

    Use Notepad++ or Sublime (or another UNIX-friendly plaintext editor) to edit the .bashrc file, and NOT Notepad or Wordpad. If you see weird errors like "\r command not found", navigate to the directory containing the .bashrc file and run the following line:

        tr -d '\r' < .bashrc > .bashrc
    
    and then restart Cygwin.

  2. To quickly navigate to your Data Structures files, you can add a variable that points to that directory in your .bashrc file:

       DS=/cygdrive/c/Users/YOUR_USER_NAME/Documents/PATH_TO_YOUR_DATA_STRUCTURES_FILES
    

    Then at the Cygwin prompt, you can use that variable:
       cd $DS
    
  3. To make an alias for the MinGW compiler with the options necessary for Dr. Memory, add this to your .bashrc file:

       alias memg++='i686-pc-mingw32-g++.exe -static-libgcc -static-libstdc++ -ggdb'
    

    Then when you're ready to compile code for use with Dr. Memory, you can type something like this at the Cygwin prompt:
       memg++ -o foo.exe foo_main.cpp foo_other.cpp
    
  4. After installing Dr. Memory (see instructions here: Installing Dr. Memory on Windows), if you see this error message when trying to run Dr. Memory:

       -bash: drmemory: command not found
    
    You can manually add Dr. Memory to your Cygwin path (which is different from your Windows path that the Dr. Memory installer may have already edited automatically). At the end of the .bashrc, add this line:

       PATH=$PATH:/cygdrive/c/Program\ Files\ \(x86\)/Dr.\ Memory/bin
    
  5. You may want to uncomment the following lines in .bashrc to prevent accidental deletions and overwrites:
    # alias rm='rm -i'
    # alias cp='cp -i'
    # alias mv='mv -i'