By rickramsey on Jul 13, 2011
photo courtesy of To Be A Pilgrim blog.
You may have seen The Onion's story about some recent ground-breaking research ...
If you get the same reaction every time you realize your C++ code is hopelessly tangled up with your C++ libraries, you may find some relief in this series by Darryl Gove and Stephen Clamage.
- Introduction to Libraries and Linking - How to make sure that your Oracle Solaris application links to the libraries it needs correctly and in the right order.
- Part II - Resolving Symbols in Libraries - How to use the -z defs flag in your code to make sure the runtime linker links your application to the correct C++ libraries.
- Part III - What Happens When An Application Starts - How investigate run-time application linking problems by using the LD_DEBUG environment variable.
- Part IV - Avoiding Linking Problems - How to identify duplicate symbols and circular dependencies in your C++ code that would lead to linking problems between your application and its libraries.
- Part V - Libraries in C++ - A detailed demonstration of how your C++ compiler can bind to a symbol from the incorrect library at compile time, and how to use the -g compiler flag to detect it.
- Part VI - Resolving the Initialization Order Problem - Using link *order* to resolve C/C++ library dependencies is quick, but not optimal. Better to use either -instlib to keep the compiler from generating multiple templates, or use the -Bdirect linker flag to record dependencies at run time. This article explains how.
- Part VII - Using Symbol Scoping to Avoid Linking Issues - By default, a symbol defined in a library is visible to other libraries and executables. You can limit a symbol's scope in a number of ways, including symbolic binding, hidden scope, and interposing. How to and examples described here.
- Part VIII - Concluding Remarks and Summary of Best Practices - Building an application as a combination of executables and library calls has many advantages but potential problems with the links between the executable and its libraries. By using the techniques described in this series of articles, you can identify problems and make the risks manageable.