This page does not represent the most current semester of this course; it is present merely as an archive.
C compilers exist for many architectures. D compilers exist for them too (we’ll use D later in the semester).
C files can be compiled on any Linux system using gcc -x c filename.c
, clang -x c filename.c
, or llvm-gcc -x c filename.c
. Most systems will have only one of these three installed; it does not matter which one you use.
On Windows the MinGW project has a version of gcc
that will probably work for most (though not all) labs, though you will need to install it yourself. Microsoft’s compiler toolchain can compile C using cl.exe /Tc filename.c
, but we have never tested how well it works. If you do, please report how you found it.
Alternatively, the following all attempt to create more complete POSIX-like environments for Windows:
On OS X, Xcode ships with a version of llvm-gcc
(they call it just gcc
). On newer versions of the OS it is located inconveniently (/Applications/Xcode.app/Contents/Developer/usr/bin/gcc
in 10.7 Lion
) but can be placed where you can more easily access it from the Terminal via XCode’s Preferences → Downloads → Command Line Tools → Install.
If you use another OS (FreeBSD, Haiku, Irix, etc) you probably know how run a C compiler already.
We’ll use a tool I created called hcl2d
this semester, which is written in the D language. Its Makefiles assume you are using the mainline dmd
compiler. To obtain that compiler,
dmd --version
on the command line. If you see a version number of 2.060 or greater, you are done. This should be the case in CS computer labs, including Olsson 001 and Rice 340.Debian-based Linuxes include many of the most popular distros, such as Ubuntu and Mint
add the d-language repository to your system
sudo bash -c "echo 'deb http://master.dl.sourceforge.net/project/d-apt/ d-apt main' > /etc/apt/sources.list.d/d-apt.list"
tell your system to trust the d-language repository
sudo apt-get update
sudo apt-get -y --allow-unauthenticated install --reinstall d-apt-keyring
ask to install dmd
sudo apt-get update
sudo apt-get install dmd-bin
On c9.io or koding.com, open a terminal and run
curl -fsS https://dlang.org/install.sh | bash -s dmd
On almost any OS you can, go to the dlang download page and download and run the installer for your platform.
Why D? Because after learning over 70 programming languages, it is the one I most want to use if writing more than half a dozen lines, and the one whose features I most often miss when writing in other languages.
Not perfect, though. It does not have language-level discriminant unions. ☹
— Prof. Tychonievich