To compile source code (the .c text files) into program executables or binaries, we need to use a C compiler, such as gcc (the GNU C Compiler), or clang (the LLVM C compiler) which translates the high level source code into assembly which is the low-level code your CPU actually understands and then into machine code which is the numeric representation of the assembly that the CPU actually runs.
If we have a program source file, such as hello.c, we could use gcc to compile it like:
hello.c
gcc -o hello hello.c
Which tells gcc to compile hello.c as a program called hello (the -o option tells gcc to use hello as the output, rather than a.out which is the default.)
hello
-o
a.out
That is cumbersome to type, so we can automate it using the make program, which reads a Makefile file which contains instructions on how to make the program or programs you want to make. This Makefile has already been setup for you, so it's ready to build all the programs in the h2 assignment directory.
make
Makefile
h2
For your first assignment you are asked to use make to build the programs you create by editing the three source files. To use make, just type:
at the prompt, while in the h2 directory and it will attempt to build the programs. To build a specific program, you can type:
make hello
for example to build the hello program. To test your programs after you have made them, you can run them by typing:
./hello
at the prompt for example (this is telling the computer to run the hello program that is found in the current working directory.) To run one of the already working examples to see how it works, if you're already in the h2 directory you can type:
./working/hello
And that will run the hello found in the working sub-directory.
working
If for some reason there is a problem compiling, you may see it print some error messages or warnings. You should not ignore these. If you do not understand what they mean, please consider asking what they mean on the forum in blackboard, so that others who may encounter them can learn what they mean or at least email me for some guidance.
To automate the process of building your programs and then checking them with the handin --hwcheck option, I've made a script called check which basically does everything for you automatically. So if you want to build your programs and check your work in one command, use:
handin --hwcheck
check
while in the assignment directory and it should do the equivalent to:
make cd .. handin --hwcheck h2
cd ..
handin --hwcheck h2