Personal web server - Chapter 29 . Programming Tools and Utilities 789

Chapter 29 . Programming Tools and Utilities 789 $ gcc file1.c file2.c file3.c -o progname gcc would create file1.o, file2.o, and file3.o and then link them all together to create progname. As an alternative, you can use gcc s -c option on each file individually, which creates object files from each file. Then in a second step, you link the object files together to create an executable. Thus, the single command just shown becomes: $ gcc -c file1.c $ gcc -c file2.c $ gcc -c file3.c $ gcc file1.o file2.o file3.o -o progname One reason to do this is to avoid recompiling files that haven t changed. If you change the source code only in file3.c, for example, you don t need to recompile file1.c and file2.c to recreate progname. Another reason to compile source code files individually before linking them to create the executable is to avoid longrunning compilation. Compiling multiple files in a single gcc invocation can take a while if one of the source code modules is really lengthy. Let s take a look at an example that creates a single binary executable from multiple source code files. The example program named newhello is comprised of a C source code file, main.c (see Listing 29-1); a header file, msg.h (see Listing 29-2); and another C source code file, msg.c (see Listing 29-3). Listing 29-1: Main Program for newhello /* * main.c _ driver program */ #include #include msg.h int main(int argc, char *argv[]) { char msg_hi[] = { Hi there, programmer! }; char msg_bye[] = { Goodbye, programmer! }; printf( %sn , msg_hi); prmsg(msg_bye); return 0; }
You want to have a cheap webhost for your apache application, then check apache web hosting services.

Leave a Reply