Programming in C

(Barry) #1
494 Appendix C Compiling Programs with gcc

Command-Line Options

Ta b le C.2 contains a list of common options used for compiling C programs.

Ta ble C.2 Commonly Used gccOptions
Option Meaning Example
--help Displays summary of common gcc --help
command-line options.
-c Does not link the files, saves the gcc –c
object files using .o for the enumerator.c
suffix of each object file.
-dumpversion Displays current version of gcc. gcc -dumpversion
-g Includes debugging information, gcc –g testprog.c
typically for use with gdb(use –o testprog
–ggdbif multiple debuggers are
supported).
-D id In the first case, defines the identifier gcc –D DEBUG=3
-D id=value idto the preprocessor with value 1. test.c
In the second case, defines the identifier
idand sets its value to value.
-E Just preprocesses files and writes results gcc –E
to standard output; useful for examining enumerator.c
the results of preprocessing.
-I dir Adds directory dirto the list of gcc –I /users/
directories to be searched for header steve/include x.c
files; this directory is searched before
other standard directories.
-llibrary Resolves library references against the gcc
file specified by library.This option mathfuncs.c -lm
should be specified after the files that need
functions from the library.The linker
searches standard places (see the –Loption)
for a file named liblibrary.a.
-L dir Adds directory dirto the list of directories gcc –L /users/
to be searched for library files.This directory steve/lib x.c
is searched first before other standard directories.
-o execfile Places the executable file in the file named gcc dbtest.c –o
execfile. dbtest

22 0672326663 AppC 6/10/04 2:02 PM Page 494

Free download pdf