Review


Know the Concepts

  • What are the advantages and disadvantages of shared libraries?

  • Given a library named 'foo', what would the library's filename be?

  • What does the ldd command do?

  • Let's say we had the files foo.o and bar.o, and you wanted to link them together, and dynamically link them to the library 'kramer'. What would the linking command be to generate the final executable?

  • What is typedef for?

  • What are structs for?

  • What is the difference between a data element of type int and int *? How would you access them differently in your program?

  • If you had a object file called foo.o, what would be the command to create a shared library called 'bar'?

  • What is the purpose of LD_LIBRARY_PATH?

Use the Concepts

  • Rewrite one or more of the programs from the previous chapters to print their results to the screen using printf rather than returning the result as the exit status code. Also, make the exit status code be 0.

  • Use the factorial function you developed in the Section called Recursive Functions in Chapter 4 to make a shared library. Then re-write the main program so that it links with the library dynamically.

  • Rewrite the program above so that it also links with the 'c' library. Use the 'c' library's printf function to display the result of the factorial call.

  • Rewrite the toupper program so that it uses the c library functions for files rather than system calls.

Going Further

  • Make a list of all the environment variables used by the GNU/Linux dynamic linker.

  • Research the different types of executable file formats in use today and in the history of computing. Tell the strengths and weaknesses of each.

  • What kinds of programming are you interested in (graphics, databbases, science, etc.)? Find a library for working in that area, and write a program that makes some basic use of that library.

  • Research the use of LD_PRELOAD. What is it used for? Try building a shared library that contained the exit function, and have it write a message to STDERR before exitting. Use LD_PRELOAD and run various programs with it. What are the results?




Programming from the Ground Up
Programming from the Ground Up
ISBN: 0975283847
EAN: 2147483647
Year: 2006
Pages: 137

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net