gccReleased 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 gcc on a source code file simply by typinggcc filename The default executable output of gcc is "a.out", which can be run by typing ./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 outputfileAgain, you can run your program with "./outputfile". (The ./ is there to ensure you run the program for the current working directory.) Catching Problems EarlyIn order to compile with all warnings enabled and to produce ANSI C compatible code, I recommend using the flags-Wall -ansiYou can read more on the value of compiler warnings. If you want to have the compiler treat warnings as errors--meaning you don't even get an executable, you can use the -Werror flag. This will make sure you don't miss an error. GDB Ready CodeIf you want to prepare your executable for use by GDB, include the -g flag .gcc filename -Wall -ansi -g -o outputfileThis 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 LibraryIf 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 -lmNote that you do not need to use this flag with C++. Find Out MoreIf you are using a *nix system, you can also check out the other gcc commandline options by typingman gcc Creating shared librariesIf you want to learn how to create a shared library on Linux with GCC, check out the article how to create a shared library on Linux using GCC |