Setting up C++ for Data Structures

This material is compiled with the help of many mentors over the years. Special thanks to Micheal Gardner and Lee Cattarin for their edits on prior versions of this document.

Remember to leave install fest with the following tools and skills:

  • A compiler that works
  • Ability to compile and run a program on the terminal

It is also a good idea to have an editor or an IDE that works. If you have additional time, install an editor and ask a mentor or TA to show you how to use it. But this is less important. Below are instructions on possible ways to accomplish this.

Installing a terminal and a compiler

Data Structures requires that your C++ code compile and run on the gcc/g++ 4.8.x compiler. You may also use clang++, which provides more concise and clear error messages. How you install a compiler will depend on your operating system, which requires the compiler program and a Terminal to run it on.

BUT it is not necessary to go through “Helpful edits to the Cygwin .bashrc file” right now.
  • If you have a Mac, you’ll need XCode, which provides both a compiler and an IDE for you.

    For Data Structures, make sure to install XCode’s “Command Line Tools” so that you can compile and run your code in the terminal as well as the IDE. Install instructions for XCode and XCode Command Line Tools can be found:

    You can then run a Terminal window: Terminal under Applications->Utilities in Macs (black box)

  • If you have a Linux OS such as Ubuntu, installing is easy. Run the following three commands in a terminal window:

    sudo apt-get install g++
    sudo apt-get install clang++-3.8
    sudo apt-get install gcc-multilib g++-multilib

Choosing an editor or IDE (Integrated Development Environment)

A text editor will allow you to view and edit your code (often with syntax highlighting or other features), but not compile and run - you have to do that in a terminal (cygwin, for Windows). An IDE will do all of these things, but might take more time to learn how to navigate as they are usually fuller-featured. Whichever you choose, you will still have to learn how to compile and run your code in a terminal, as that is the primary method to get help or show completeness in lab.

If you are having trouble deciding, ask the TAs and mentors what they use!

Remember: IDEs are useful for debugging with a graphical user interface. But, it is likely that no one will be an expert in the specific IDE you use. Practice and learn its features before starting to use it in class assignments.

Final Note

If you find additional resources that are useful, please feel free to let us know. We will include them here.