CSCI 1200 Data Structures
Spring 2017

  Contact Information
   Forums (Piazza)

  Learning Outcomes
  iClickers in Lecture
  Course Grades

  Lecture notes
  Lab materials
  Test reviews

Weekly Schedule
  Office Hours
  Lab Times

Getting Help
  Advice from TAs
  Advice from Students

  Due Date and Time
  Late Day Policy
  HW Grading Criteria

Collaboration Policy &
Academic Integrity

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

  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. If you don't have either, we recommend you use the 64 bit version.

  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 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 "".

    • 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.

      Next, type "mingw64-i686-gc" in the search box. Click on "Skip" for "mingw64-i686-gcc-g++: GCC for Win32 (i686-w64-mingw32) toolchain(C++)" until the version number appears.
      CAUTION: Don't pick the one with Win64, or you'll be missing some error types in the Dr. Memory memory debugger.

    • Then, type "gdb" in the search box. Open up the "Devel" section, and cick on "Skip" "gdb: The GNU Debugger" until the version number appears.

    • 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:


    Then at the Cygwin prompt, you can use that variable:
       cd "$DS"
    The single quotes around $DS ensure that even if your path has a space in it, Cygwin handles it correctly.
  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-w64-mingw32-g++.exe --static -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'
  6. You may need to edit your .bash_profile to add a call to your .bashrc for the above instructions to work. Use Notepad++ or Sublime to open c:\Cygwin\home\YOUR_USERNAME\.bash_profile And add this line at the end:
       . ~/.bashrc