Compiling C files is not difficult; the harder part is to write the
files, and I can't write a C manual in this HOWTO. Please search the
Internet, where there are lots of sites with help on C, or any book on C
programming.
Compiling with gcc
First of all, the C compiler expect the name of the file to end in .c for a C file, and .cc for a C++ file (there are other endings, for assembly and include files, but I will not talk about those files here).
The compiling part is simple, just do
gcc file.cfor a C file or
g++ file.ccfor a C++ file.
The output (executable) file will be called a.out If you want to get the output in a different file, do:
gcc -o output-file file.cThere are many options you can give to the compiler. A common one is to get "all warnings" with
gcc -Wall file.cIf you need to include some library, say the library with the crypt functions, called libcrypt.a, then do
gcc -lcrypt file.cSome times libraries are not found by the compiler, you will have to provide the directory where the library is. For example, the library libconv-core.a from the charm package is in /usr/local/char/lib. Then you can compile with
gcc -L/usr/local/char/lib -lconv-core file.cThe -L option is to tell the compiler to search for libraries in that directory; the -l is, as above, to include the library in the compiling process.
To debug a C program you will have to compile it in a particular way:
gcc -g file.cThe debugging utility in the GNU C compiler is called gdb You can run it on the executable file with:
gdb a.outor
xxgdbfor debugging in X-windows.
There are several utilities to do parallel compiling. Here is some more information:
Search the Internet for more documentation. If you find something useful, please send a mail to the webmaster so I can put it in our website.