Compiling and Running Software
Many of the assignments for this course require
you to compile and run small .c and c++ programs.
You may do this on any machine or architecture
you like, including Linux, Windows, or Mac OS X.
We will endeavor to make sure the code runs on
all three of these platforms, but you must do
some work on this as well. Here are a set of
tips, observations, etc. that will help you get
going on compiling and running the code.
- Pick one architecture to do your work and stick
with it if possible. Best to even pick one actual
machine and stick with that. You'll see why from
some of the other points below.
- Edit the waveio.h file, and change the #define
to either LITTLENDIAN or BIGENDIAN, depending on
your platform. Windows and Linux on Intel/PC
processors use LITTLENDIAN. Macs use BIGENDIAN.
Why is this necessary? See this interesting
- Much of the code for this class works in
a simple command line interface. This is the
shell for Linux and Mac, and is the old-fashioned
DOSBox (command.com) for Windows machines. You
need to have a compiler, and there are many.
gcc, cc, CC or maybe others should be native
on Linux and Mac (if developer tools have been
installed) machines. Windows machines may or
may not, but often do not have a compiler.
Free C compilers include
lcc (originally from Princeton!)
gcc via cygwin
standalone, bcc from Borland,
gcc via MingW for Windows, THIS IS RECOMMENDED
You can try the .Net compiler (cl) which is free from MicroSoft.
For this, you need both the
Framework, download and install this first.
SDK, download and install this second. NOTE: I was unable to get this to work
from a clean platform.
- Different compilers react differently to
various things. For example, some Linux compilers
(gcc) need the #include file malloc.h, while most
other compilers (even gcc on other platforms like
Mac OS X) have no idea what malloc.h is. If your
compiler complains about some #include, just
comment it out and try again. If it complains
that it can't find some function, then let us
know. Read on...
- One thing that you might experience on some
compilers is the math.h functions, like sin(),
cos(), pow(), etc. aren't automatically linked.
To fix this just add -lm to the end of your compiler
directive to explicitly tell the compiler to link
the math library:
gcc -o test test.c -lm
- MORE COMING AS NECESSARY