Google
 
Webcprogramming.com




An Affiliate of AIHorizon




gcc

Released by the Free Software Foundation, gcc is a *nix-based C compiler usually operated via the command line. It often comes distributed with a *nix installation, so if you are running Unix or a Linux variant you likely have it on your system. You can invoke gc on a source code file simply by typing
gcc filename


The default executable output of gcc is "a.out". It is also possible to specify a name for the executable file at the command line by using the syntax
-o outputfile
, as shown in the following example:
gcc filename -o outputfile

GDB Ready Code

If you want to prepare your executable for use by GDB, include the -g flag .
gcc filename -g -o outputfile
This will enable GDB to give you detailed debugging information by including extra code in the executable file to allow GDB to find variable names and list the source code.

Math Library

If you need to use functions from the math library (generally functions from math.h such as sin or sqrt), then you need to explicitly ask it to link with that library with the -l flag and the library 'm':
gcc filename -o outputfile -lm
Note that you do not need to use this flag with C++.

Find Out More

If you are using a *nix system, you can also check out the other gcc commandline options by typing
man gcc


-----
Interested in advertising with us?
Please read our privacy policy.
Copyright © 1997-2005 Cprogramming.com. All rights reserved.

Geodesy Designs