Professional Documents
Culture Documents
What is Linux?
An operating system, in many ways like
Windows and MacOS Free can download and installed from the Internet Countless software packages for free, and most very easy to install/uninstall
C Compiler
Free, and installed by default One of the oldest and most stable
Called: gcc
Compiling programs
At first glance, harder to use than
conventional graphical compilers There are graphical frontends, but the easiest way to get started is with the conventional command line Later we will explore Makefiles, which greatly simplify the compilation of programs
- Adding multiple filenames is similar to adding files to a Project in a graphical development environment
gcc Wall codeFile1.c -o outputFileName Provides extra warnings, useful for tracking down some bugs
Editors
like Windows editors Take days of frustration to learn how to do simple tasks, but once good at using, unbelievably powerful Huge debates on which is better, but if you decide to learn one, VIM is generally considered best for programming
getting started with Linux many of the free tutorials are quite good
Makefiles
A Makefile is the configuration file used by
a standard program called Make Make is like a project manager in a graphical development environment, but includes many extra features Allows an entire project to be intelligently built with one command on the command line
Makefiles (2)
What do we mean by intelligent building
of a program?
For small programs, we dont care about compilation time compiling and building an assignment doesnt take long When building a large project, such as an operating system, the Make utility helps by recompiling only the files that have changed since the last compilation
Dependencies
Sometimes one file depends on another
file
e.g. a C file depends on its header files If a header file changes, the C files that #include that header file should be recompiled to take into account the changes to the header
Dependencies (2)
Final executable file (MyProject.exe) main.o main.c interface.h interface.o interface.c
Dependencies (3)
Final executable file (MyProject.exe) main.o main.c interface.h interface.o interface.c
Dependencies (4)
Final executable file (MyProject.exe) main.o main.c interface.h interface.o interface.c
Multiple Targets
main.o main.c
In the Makefile:
clean: rm rf ./*.o To run make with this target, type: make clean
Variables
In a large makefile, good idea to use
variables to make later changes easy
For example, rather than typing gcc in the command part of every rule, create a variable at the top of the Makefile: COMPILER = gcc
Variables (2)
Our earlier example using a variable:
COMPILER = gcc MyProject: main.o interface.o
Resources
There are resources on the Web, such as:
http://www.eng.hawaii.edu/Tutor/Make/index.html http://www.opussoftware.com/tutorial/TutMakefile.htm
examples on your system since almost every Linux program has a Makefile