Compilers, Tools, Dev Environments, etc.
Table of Contents
- 1. Installing a Development Environment on Your Own Machine :optional:
- 2. TODO A C Development Environment
- 3. TODO A Java Development Environment
- 4. TODO Project Tools
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
- As a prerequisite, download and install Virtualbox (on macOS with homebrew:
brew cask install vagrant
) - Download Vagrant and run the downloaded file (Windows) or install it with your package manager (Linux), (on macOS with homebrew:
brew cask install vagrant
) - Open a terminal, navigate to your IOOPM GitHub repository
- Create a directory for Vagrant with
mkdir vagrant
- Tell
git
to ignore this directory withgit-ignore vagrant
(see below if you have problems with this) - Go into that directory with
cd vagrant
- Download this Vagrantfile into the
vagrant
directory and rename itVagrantfile
without any.txt
ending (e.g.,curl http://wrigstad.com/ioopm18/misc/Vagrantfile.txt -o Vagrantfile
) - 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 inVagrantfile
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
- Open a terminal, navigate to your IOOPM GitHub repository
- Run
vagrant ssh
to move inside the running virtual machine – now all commands you type run on the virtual machine instead - 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 - To disconnect from the virtual machine, simply use C-d
- To pause the virtual machine (e.g., to reserve battery power and memory), do
vagrant suspend
- To shutdown the virtual machine (e.g., to reserve battery power and memory, and some hard drive space), do
vagrant halt
- To resume a paused (suspended) vagrant box, do
vagrant resume
beforevagrant ssh
- To restart a stopped (halted) vagrant box, do
vagrant up
beforevagrant 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
andgcovr
for code coveragegprof
andperf
for profiling etc.cproto
extract function prototypes from C code- GNU
global
andcscope
code navigation tools git
andtig
version controlcunit
andjunit
unit testing frameworks for C and Javamake
andcmake
build managementdoxygen
generate documentation extracted from comments in source filesssh
andtmux
love tmux!curl
get files, interact with web APIs etc.astyle
,indent
automatic code formattinghtop
check the processes running on the machinegnuplot
andgraphviz
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
- Open https://brew.sh/ in a browser, and copy-and-paste the installation command into a terminal and execute it
- 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.4 Java JDK
Download and install from http://www.oracle.com/technetwork/java/javase/downloads/index.html
1.5.5 junit
- Official installation guide: https://junit.org/junit5/docs/current/user-guide
- Stackoverflow installation guide, probably easier: https://stackoverflow.com/a/26977630/1283083
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.