Archive for the 'Linux' Category

734 Part VI . Programming (Web site traffic) in Linux The

Saturday, December 8th, 2007

734 Part VI . Programming in Linux The nm Command The nm command lists all of the symbols encoded in an object or binary file. It s used to see what function calls a program makes or to see if a library or object file provides a needed function. nm has the following syntax: nm [options] file nm lists the symbols stored in file, which must be a static library or archive file, as described in the preceding section. options controls nm s behavior. Table 28-3 describes useful options for nm. Table 28-3 nm Command-Line Options Option Description -C Converts symbol names into user-level names. This is especially useful for making C++ function names readable. -l Uses debugging information to print the line number where each symbol is defined, or the relocation entry if the symbol is undefined. -s When used on archive (.a) files, prints the index that maps symbol names to the modules or members in which the symbol is defined. -u Only displays undefined symbols, symbols defined externally to the file being examined. Here s an example that uses nm to show some of the symbols in /usr/lib/libdl.a: $ nm /usr/lib/libdl.a | head dlopen.o: 00000040 T __dlopen_check U _dl_open U _dlerror_run 00000040 W dlopen 00000000 t dlopen_doit dlclose.o: U _dl_close
If you are looking for cheap and quality webhost to host and run your website check Jboss Web Hosting services.

Chapter 28 . (Web hosting asp) Programming Tools and Utilities 733

Friday, December 7th, 2007

Chapter 28 . Programming Tools and Utilities 733 frequently used routines, such as the output function printf() and the input function getchar() that would be wearisome to rewrite each time you create a new program. Beyond code reuse and programmer convenience, however, libraries provide a great deal of thoroughly debugged and well-tested utility code, such as routines for network programming, graphics handling, data manipulation, and system calls. You need to know the tools at your disposal for creating, maintaining, and managing programming libraries. There are two types of libraries: static and shared. Static libraries are specially formatted files that contain object files, called modules or members, of reusable, precompiled code. They are stored in a special format along with a table or map that links symbol names to the members in which the symbols are defined. The map speeds up compilation and linking. Static libraries are typically named with the extension .a, which stands for archive. Shared libraries, like static libraries, are files that contain other object files or pointers to other object files. They are called shared libraries because the code they contain is not linked into programs when the programs are compiled. Rather, the dynamic linker/loader links shared library code into programs at runtime. Shared libraries have several advantages over static libraries. First, they require fewer system resources. They use less disk space because shared library code is not compiled into each binary but linked and loaded from a single location dynamically at runtime. They use less system memory because the kernel shares the memory the library occupies among all the programs that use the library. Second, shared libraries are slightly faster because they only need to be loaded into memory once. Finally, shared libraries simplify code and system maintenance. As bugs are fixed or features added, users need only obtain the updated library and install it. With static libraries, each program that uses the library must be recompiled. The dynamic linker/loader ld.so links symbol names to the appropriate shared library in which they are defined at runtime. Shared libraries have a special name, the soname, that consists of the library name and the major version number. The full name of the C library on one of my systems, for example, is libc-2.3.2.so. The library name is libc.so; the major version number is 2; the minor version number is 3; and the release or patch level is 2. For historical reasons, the C library s soname is libc.so.6. Minor version numbers and patch level numbers change as bugs are fixed, but the soname remains the same and newer versions are usually compatible with older versions. I emphasize the soname because applications link against it. How does linking work? The ldconfig utility creates a symbolic link from the actual library, say libc-2.3.2.so, to the soname, libc.so.6, and stores this information in /etc/ld.so.cache. At runtime, ld.so scans the cache file, finds the required soname and, because of the symbolic link, loads the actual library into memory and links application function calls to the appropriate symbols in the loaded library.
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.

732 Part VI . Programming in Linux three (Web hosting contract)

Thursday, December 6th, 2007

732 Part VI . Programming in Linux three files must exist to build editor. The second line in the first rule is the command that make must execute to create editor: gcc -o editor editor.o screen.o keyboard.o. It builds the executable from the three object files, editor.o, screen.o, and keyboard.o. The next three rules tell make how to build the individual object files. Each rule consists of a one-object file target (editor.o, screen,o, keyboard.o); one source code file dependency (editor.c, screen.c, keyboard.c); and a rule that defines how to build that target. The fifth rule defines a target named clean with no dependencies. When a target has no dependencies, its commands are executed whenever the target is invoked. In this case, clean deletes the constituent object files (*.o), plus any core files (core) as well as any Emacs backup files (*~) from previous builds. The sixth rule defines a target named realclean. It uses the fifth rule as one of its dependencies. This causes make to build the clean target and then to remove the editor binary. Here is where make s value becomes evident: Ordinarily, if you tried to build editor using the command from the second line, gcc would complain loudly and ceremoniously quit if the dependencies did not exist. Make, on the other hand, after determining that editor requires these files, first verifies that they exist and, if they don t, executes the commands to create them. After creating the dependencies, make returns to the first rule to create the editor executable. Of course, if the dependencies for the components, editor.c, screen.c, or keyboard.c, don t exist, make will give up because it lacks targets named, in this case, editor.c, screen.c, or keyboard.c (that is, no rules are defined in the makefile for creating editor.c, screen.c, and keyboard.c). All well and good, you are probably thinking, but how does make know when to build or rebuild a file? The answer is simple: If a specified target does not exist in a place where make can find it, make builds or rebuilds it. If the target does exist, make compares the timestamp on the target to the timestamp on the dependencies. If one or more of the dependencies are newer than the target, make rebuilds that target, assuming that the newer dependency implies some code change that must be incorporated into the target. Library Utilities Programming libraries are collections of code that can be reused across multiple software projects. Libraries are a classic example of software development s ardent goal, code reuse. They collect frequently used programming routines and utility code into a single location. The standard C libraries, for example, contain hundreds of
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

Mac os x web server - Chapter 28 . Programming Tools and Utilities 731

Wednesday, December 5th, 2007

Chapter 28 . Programming Tools and Utilities 731 target : dependency dependency […] command command […] target is usually the file, such as a binary or object file, to create. dependency is a list of one or more files required as input to create target. Each command is a step such as a compiler invocation or a shell command that is necessary to create target. Unless specified otherwise, make does all of its work in the current working directory. The first character in a command must be the tab character; eight spaces will not suffice. This often catches people unaware and can be a problem if your preferred editor helpfully translates tabs to eight spaces. If you try to use spaces instead of a tab, make displays the message Missing separator and stops. Listing 28-4 shows a sample makefile for building a text editor imaginatively named editor. Listing 28-4: A Sample Makefile editor : editor.o screen.o keyboard.o gcc -o editor editor.o screen.o keyboard.o editor.o : editor.c gcc -c editor.c screen.o : screen.c gcc -c screen.c keyboard.o : keyboard.c gcc -c keyboard.c clean : rm -f *.o core *~ realclean : clean rm -f editor To compile editor, you would simply type make in the directory that contains the makefile. It s that simple. This example makefile has six rules. The first defines how to create the target named editor. The first target in every makefile is the default target (unless you specifically define one using the .DEFAULT directive, which is not covered in this chapter). The default target is the one that make builds if no target is specified as an argument to make. editor has three dependencies, editor.o, screen.o, and keyboard.o; these Caution
If you are in need for chaep and reliable webhost to host your website, our recommendation is http web server services.

730 Part VI (Web server hosting) . Programming in Linux As

Tuesday, December 4th, 2007

730 Part VI . Programming in Linux As mentioned earlier, -o file tells GCC to place output in the file file regardless of the output being produced. If you do not specify -o, for an input file named file. suffix, the defaults are to name the executable a.out, the object file file.o, and the assembly language file file.s. Preprocessor output goes to stdout. Automating Builds with Make The make utility is a tool to control the process of building and rebuilding software. Make automates what software gets built, how it gets built, and when it gets built, freeing programmers to concentrate on writing code. It also saves a lot of typing because it contains logic that invokes GCC compiler-appropriate options and arguments. Use this section to familiarize yourself with the look and layout of a makefile. For all but the simplest software projects, make is essential. In the first place, projects composed of multiple source files require long, complex compiler invocations. Make simplifies this by storing these difficult command lines in the makefile, a text file that contains all of the commands required to build software projects. Make is convenient for both the developer and the user who want to build a program. As developers make changes to a program, whether to add new features or incorporate bug fixes, make makes it possible to rebuild the program with a single, short command. Make is convenient for users because they don t have to read reams of documentation explaining in excruciating, mind-numbing detail how to build a program. Rather, they can simply be told to type make followed by make test followed by make install. Most users appreciate the convenience of simple build instructions. Finally, make speeds up the edit-compile-debug process. It minimizes rebuild times because it is smart enough to determine which files have changed, and only recompiles files that have changed. So, how does make accomplish its magical feats? By using a makefile, which contains rules that tell make what to build and how to build it. A rule consists of the following: . A target, the thing make ultimately tries to create . A list of one or more dependencies (usually files) required to build the target . A list of commands to execute to create the target from the specified dependencies Makefiles constitute a database of dependency information for the programs they build and automatically verify that all of the files necessary for building a program are available. When invoked, GNU make looks for a file named GNUmakefile, makefile, or Makefile, in that order. For some reason, most Linux programmers use the last form, Makefile. Makefile rules have the general form
If you are in need for chaep and reliable webhost to host your website, our recommendation is http web server services.

Chapter 28 . Programming Tools (Top ten web hosting) and Utilities 729

Monday, December 3rd, 2007

Chapter 28 . Programming Tools and Utilities 729 Table 28-2 GCC Command-Line Options Option Description -ansi Supports the ANSI/ISO C standard, turning off GNU extensions that conflict with the standard. -c Compiles without linking, resulting in an object file but not an executable binary. -Dfoo=bar Defines a preprocessor macro foo with a value of bar on the command line. -g Includes standard debugging information in the binary. -ggdb Includes lots of debugging information in the binary that only the GNU debugger (GDB) can understand. -Idirname Prepends dirname to the list of directories searched for include files. -Ldirname Prepends dirname to the list of directories searched for library files. By default, gcc links against shared libraries. -lfoo Links against libfoo. -MM Outputs a make-compatible dependency list. -o file Creates the output file file (not necessary when compiling object code). If file not specified, the default is a.out. -O Optimizes the compiled code. -On Specifies an optimization level n, 0<=n<=3. -pedantic Emits all warnings required by the ANSI/ISO C standard. -pedantic- Emits all errors required by the ANSI/ISO C standard. errors -static Links against static libraries. -traditional Supports the Kernighan and Ritchie C syntax (if you don t understand what this means, don t worry about it). -v Shows the commands used in each step of compilation. -W Suppresses all warning messages. -Wall Emits all generally useful warnings that gcc can provide. Specific warnings can also be flagged using -Wwarning. -werror Converts all warnings into errors, stopping the compilation.
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.

Web space - 728 Part VI . Programming in Linux Listing

Monday, December 3rd, 2007

728 Part VI . Programming in Linux Listing 28-3: Definitions for newhello Helper Function /* * msg.c - function declared in msg.h */ #include #include msg.h void prmsg(char *msg) { printf( %sn , msg); } The command to compile these programs to create newhello is $ gcc msg.c showit.c -o newhello To create the object files individually, you might use the following commands: $ gcc -c msg.c $ gcc -c showit.c Then, to create newhello from the object files, use the following command: $ gcc msg.o showit.o -o newhello Running this program, the output is: $ ./newhello Hi there, programmer! Goodbye, programmer! Before it creates the newhello binary, gcc creates object files for each source file. Typing long commands like this does become tedious, however. The section titled Automating Builds with Make later in this chapter shows you how to avoid having to type long, involved command lines. GCC Command-Line Options The list of command-line options GCC accepts runs to several pages, so Table 28-2 describes only the most common ones.
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

Chapter 28 . Programming Tools and (Hosting web) Utilities 727

Sunday, December 2nd, 2007

Chapter 28 . Programming Tools and Utilities 727 One reason to do this is to avoid recompiling files that haven t changed. If you only change the source code in file3.c, for example, you wouldn 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 long-running compilation. Compiling multiple files in a single gcc invocation can take awhile 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, showit.c (Listing 28-1); a header file, msg.h (Listing 28-2); and another C source code file, msg.c (Listing 28-3). Listing 28-1: Main Program for newhello /* * showit.c _ driver */ #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; } Listing 28-2: Header file for newhello Helper Function /* * msg.h - header for msg.c */ #ifndef MSG_H_ #define MSG_H_ void prmsg(char *msg); #endif /* MSG_H_ */
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.

726 Part VI . Programming in Linux GCC (Post office web site)

Saturday, December 1st, 2007

726 Part VI . Programming in Linux GCC relies on file extensions to determine what kind of source code file it is, that is, in which programming language the source code is written. Table 28-1 lists the most common extensions and how GCC interprets them. Table 28-1 GCC s File Naming Conventions Extension Type .a, .so Compiled library code .c C language source code .C, .cc C++ language source code .i Preprocessed C source code .ii Preprocessed C++ source code .m Objective-C source code .o Compiled object code .S, .s Assembly language source code Compiling Multiple Source Code Files Most nontrivial programs consist of multiple source files, and each source file must be compiled to object code before the final link step. To do so, provide gcc the name of each source code file it has to compile. GCC handles the rest. The gcc invocation might resemble: $ 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
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

Web design online - Chapter 28 . Programming Tools and Utilities 725

Friday, November 30th, 2007

Chapter 28 . Programming Tools and Utilities 725 (Kernighan and Ritchie) C. You can control the amount and type of debugging information, if any, to embed in the resulting binary. And like most compilers, GCC can also perform code optimization. The gcc command invokes the C compiler. To use it, provide it the name of a C source file and use its -o option to specify the name of the output file. gcc will preprocess, compile, assemble, and link the program, generating an executable, often called a binary. Here s the simplest syntax : gcc infile.c [-o outfile] infile.c is a C source code file and -o says to name the output file outfile. The [] characters indicate optional arguments throughout this book. If the name of the output file is not specified, gcc names the output file a.out by default. The following example uses gcc to create the hello program from the source file hello.c. First, the source code: /* * hello.c - canonical hello world program */ #include int main(int argc, char *argv[]) { printf( Hello, Linux programming world!n ); return 0; } Now, to compile and run this program, type $ gcc hello.c -o hello If all goes well, gcc does its job silently and returns to the shell prompt. It compiles and link the source file hello.c (gcc hello.c), creating a binary named hello, as specified using the -o hello argument. If you run the program, here s the output you get: $ ./hello Hello, Linux programming world! The command that executed the hello program specifically included the current directory, denoted with a ., because having the current directory in your path is a security risk. That is, instead of a $PATH environment variable that resembles /bin:/usr/bin:/usr/local/bin:., it should be /bin:/usr/bin:/usr/ local/bin so that a cracker cannot put a dangerous command in your current directory that happens to match the name of the more benign command you really want to execute. Caution
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.