This page does not represent the most current semester of this course; it is present merely as an archive.
This lab is optional. Olsson 001 will not be staffed today, so you'll need to do it on your own. If you run into problems, use Piazza to get help.
We will use C (not C++, C#, Objective-C, Ch, C0, C--, or any other C-named language) in much of this class. C is very close to machine language without the headaches associated with assembly.
We do not have the staffpower to support arbitrary student systems or arbitrary C compilers. If the suggestions below fail for any reason, our official answer is you may program on the lab machines instead.
It is on you to schedule enough time with access to those machines in order to complete your assignments. Excuses such as my computer crashed
or I had trouble installing the compiler
will not be accepted.
That said, we will sometimes provide suggestions for how a lab or homework could be done from your home machine. If those work for you, great. If they do not, you may program on the lab machines instead.
If you have your own tip, post it on piazza so everyone can benefit.
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.
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 assume you'll use Linux for the labs in this course.
Upon logging into Linux, you'll want access to
I suggest getting the terminal first by pressing Alt-F2 and typing gnome-terminal
, konsole
, or xterm
(they may not all work, but at least one should). You can also get to these from
You can then get an editor by typing into the terminal one of geany &
, gedit &
, kate &
, nano
, pico
, emacs
, or vim
(or others, if you know others); and you can get a browser with firefox &
or chromium-browser &
.
Other important commands you can use in the terminal:
pwd
tells you where you are currently in the file systemls
tells you what files are in the current foldermkdir
makes a new directorycd ..
go one spot higher in the directory tree (if you are in /home/mst3k/funbox/whee/
then cd ..
will move you to /home/mst3k/funbox/
)cd dirname
to enter directory dirname (if you are in /home/mst3k/funbox/
then cd whee
will move you to /home/mst3k/funbox/whee/
)In a pinch, there are lots of online compilers out there. You might try (in alphabetical order)
Cloud9 – Can be used in demo mode, but you should probably sign up for free and use the private workspace instead.
I have had success getting benchmarked code to work in c9.io: in the terminal type sudo apt-get update; sudo apt-get install gcc-multilib libc6-dev-i386
and then the timing code we use in lab will work on the cloud too.
codepad – no login, but code is public so be careful to avoid cheating.
I have not yet had success getting course code to work in codepad.org.
codio – account needed but free; the private project each user may have (with the empty template) is plenty for this class.
I have not yet had success getting benchmarked code to work in codio.com.
compileonline – no login, and I was unable to find intellectual property information.
I have not yet had success getting course code to work in compileonline.com.
ideone – Can be used in demo mode, but you should probably sign up for free instead.
I have not yet had success getting course code to work in ideone.com.
Koding – accounted needed; free for educational use.
I have had success getting benchmarked code to work in koding.com, although it was quite slow to run. To get set up, in the terminal type sudo apt-get install gcc-multilib libc6-dev-i386 make
and then the timing code we use in lab will work on the cloud too.
ShiftEdit – accounted needed; free for educational use.
I have not yet had success getting course code to work in shiftedit.
If you know of other online c compilers or have comments about these, tell your instructor so we can update this list.
One of the most reliable ways to get a compliant C compiler if you don't run some kind of POSIX-compliant system is to install Linux via virtualbox.
You might already have a Linux virtual box from taking 2150. If you don't, get virtualbox and some Linux distro (Don't know which one? The labs use Kubuntu, but I hear nicer things about LMDE and xubuntu.). There are lots of tutorials on installing Linux on virtualbox online.
You may also use the virtualbox image Aaron Bloomfield created for CS 2150; see his tutorials on VirtualBox, Unix, and how he made the image if you wish. You'll find his image on collab's resources page, along with a smaller, less feature-rich image I made. Windows' built-in zip support might hang on such large files; if so, download 7zip to open them.
If you think you have a compiler properly installed,
hello.c
from Figure 1.1 on page 2 of the textbook