Datasheet

532
Exploring the Software-Development Tools in Linux
A debugger for debugging programs. Linux includes the GNU
debugger gdb.
A version-control system to keep track of various revisions of a
source file. Linux comes with RCS (Revision Control System) and CVS
(Concurrent Versions System). Nowadays, most open source projects
use CVS as their version control system, but a recent version control
system called Subversion is being developed as a replacement for CVS.
You can install these software-development tools in any Linux distribution:
Xandros: Usually, the tools are installed by default.
Fedora: Select the Development Tools package during installation.
Debian: Type apt-get install gcc and then apt-get install
libc6-dev in a terminal window.
SUSE: Choose Main MenuSystemYaST, click Software on the left side
of the window, and then click Install and Remove Software. Type gcc in
the search field in YaST, select the relevant packages from the search
results, and click Accept to install. If you find any missing packages, you
can install them in a similar manner.
The next few sections briefly describe how to use these software-develop-
ment tools to write applications for Linux.
GNU C and C++ compilers
The most important software-development tool in Linux is GCC — the GNU
C and C++ compiler. In fact, GCC can compile three languages: C, C++, and
Objective-C (a language that adds object-oriented programming capabilities
to C). You use the same gcc command to compile and link both C and C++
source files. The GCC compiler supports ANSI standard C, making it easy to
port any ANSI C program to Linux. In addition, if you’ve ever used a C com-
piler on other UNIX systems, you should feel right at home with GCC.
Using GCC
Use the gcc command to invoke GCC. By default, when you use the gcc
command on a source file, GCC preprocesses, compiles, and links to create
an executable file. However, you can use GCC options to stop this process
at an intermediate stage. For example, you might invoke gcc by using the -c
option to compile a source file and to generate an object file, but not to per-
form the link step.
Using GCC to compile and link a few C source files is easy. Suppose you
want to compile and link a simple program made up of two source files. To
42_770191-bk08ch01.indd 53242_770191-bk08ch01.indd 532 8/6/10 9:51 AM8/6/10 9:51 AM