Web
Analytics
 

Compilers, Tools, Dev Environments, etc.

Table of Contents

This text is being written from scratch in 2018. For now, refer to the bootstrap sections on the C bootstap labs and Assignment 1.

1 Installing a Development Environment on Your Own Machine :optional:

For those who do not want to tinker with their own machines, we suggest installing Vagrant to run a small virtualized Linux machine inside your computer to compile, debug, profile, etc. This will make it easier to remove any IOOPM-related file after the course, but also provides a dead-simple way to get a machine with all the necessary software. You can still install e.g., Emacs natively and edit your files through a graphical program, but compile and run in the virtual machine. Typically macOS users will suffer from tools like Valgrind reporting ghost errors (because Valgrind isn’t up to date with the latest macOS release yet), etc. Running inside a faux Linux machine fixes these problems.

Vagrant has pretty decent documentation, that is way more comprehensive than below.

1.1 Installing Vagrant

  1. As a prerequisite, download and install Virtualbox (on macOS with homebrew: brew cask install vagrant)
  2. Download Vagrant and run the downloaded file (Windows) or install it with your package manager (Linux), (on macOS with homebrew: brew cask install vagrant)
  3. Open a terminal, navigate to your IOOPM GitHub repository
  4. Create a directory for Vagrant with mkdir vagrant
  5. Tell git to ignore this directory with git-ignore vagrant (see below if you have problems with this)
  6. Go into that directory with cd vagrant
  7. Download this Vagrantfile into the vagrant directory and rename it Vagrantfile without any .txt ending (e.g., curl http://wrigstad.com/ioopm18/misc/Vagrantfile.txt -o Vagrantfile)
  8. Run the command vagrant up – this will (only the first time, unless you destroy your virtual machine) download the vitual machine according to the specification in Vagrantfile and install the necessary packages

If you are prompted with a dialogue for choosing LOCALE during vagrant up, choose utf-8 (should be pre-selected).

Vissa (möjligen endast Windows-användare) har problem med git-ignore. Lös detta genom att skapa en fil som heter .gitignore (observera inledande .) och som innehåller ordet vagrant på första raden.

1.2 Using Vagrant

  1. Open a terminal, navigate to your IOOPM GitHub repository
  2. Run vagrant ssh to move inside the running virtual machine – now all commands you type run on the virtual machine instead
  3. To find the files in your repo, navigate to cd /ioopm – typing e.g. clang -c assignment1/hash_table.c will compile the file in the virtual machine
  4. To disconnect from the virtual machine, simply use C-d
  5. To pause the virtual machine (e.g., to reserve battery power and memory), do vagrant suspend
  6. To shutdown the virtual machine (e.g., to reserve battery power and memory, and some hard drive space), do vagrant halt
  7. To resume a paused (suspended) vagrant box, do vagrant resume before vagrant ssh
  8. To restart a stopped (halted) vagrant box, do vagrant up before vagrant ssh

1.3 What is Installed in the Virtual Linux Box?

The following is installed (with the exception of to-be-added):

  • C compilers: gcc, clang
  • C debuggers: gdb, lldb
  • Java: openjdk 8
  • Editors: Emacs 25, Vim 8 (note: both are text-only – no graphical components)
  • valgrind for debugging memory errors, finding memory leaks, and more!
  • gcov and gcovr for code coverage
  • gprof and perf for profiling etc.
  • cproto extract function prototypes from C code
  • GNU global and cscope code navigation tools
  • git and tig version control
  • cunit and junit unit testing frameworks for C and Java
  • make and cmake build management
  • doxygen generate documentation extracted from comments in source files
  • ssh and tmux love tmux!
  • curl get files, interact with web APIs etc.
  • astyle, indent automatic code formatting
  • htop check the processes running on the machine
  • gnuplot and graphviz to draw diagrams – used by doxygen (and you?)
  • terminal emulators: bash, zsh
  • convenience: oh-my-zsh, zip, unzip
  • to-be-added: tag, some aliases

Feel free to look up all of these programs and learn about them.

1.4 Manually Installing Most of the Above in a Linux System with apt-get

$ sudo apt-get install -y gcc clang libclang-dev lldb emacs25 vim tree make \
       tmux curl astyle zsh linux-tools-common valgrind git libcunit1-dev doxygen \ 
       xclip global zip unzip openjdk-8-jdk linux-tools-generic \
       cscope cproto gcovr tig htop junit gnuplot graphviz cmake indent

where \ is a line break in the terminal and completely optional – used here for formatting.

1.5 Using Homebrew on macOS and Skip Virtualbox

  1. Open https://brew.sh/ in a browser, and copy-and-paste the installation command into a terminal and execute it
  2. Install the individual components in the list of software above, e.g., through brew install gcc, etc. – use this search index for finding brew packages

1.5.1 Homebrew and most packages

If not installed, install homebrew: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Using homebrew, you can install the above thus:

brew install astyle cmake cproto cscope cunit curl doxygen gcovr git \
     global gnuplot graphviz htop make tig tmux tree unzip valgrind \
     vim xclip zip zsh

where \ is a line break in the terminal and completely optional – used here for formatting.

1.5.2 Installing Emacs

Install from https://emacsformacosx.com or use homebrew!

1.5.3 clang and libclang-dev

Install Xcode.app via App Store or run gcc in the terminal. If not installed, a dialogue will appear – follow it.

1.5.5 junit

1.6 TODO Installing Tools in the Linux Subsystem of Windows   help_wanted

A step-by-step description of this, or information about how it is not possible, is much welcome.

2 TODO A C Development Environment

3 TODO A Java Development Environment

4 TODO Project Tools

  • Trello etc.

Questions about stuff on these pages? Use our Piazza forum.

Want to report a bug? Please place an issue here. Pull requests are graciously accepted (hint, hint).

Nerd fact: These pages are generated using org-mode in Emacs, a modified ReadTheOrg template, and a bunch of scripts.

Ended up here randomly? These are the pages for a one-semester course at 67% speed on imperative and object-oriented programming at the department of Information Technology at Uppsala University, ran by Tobias Wrigstad.

Author: Tobias Wrigstad

Created: 2019-04-19 Fri 17:38

Validate