title: How to force gcc to link unreferenced, static C++ objects from a library
body: <p>I'm using a C++ library that can be built as either a shared or a static library.
  This library uses a factory technique, where static objects register themselves when the program starts and the static objects get created.</p>
  
  <p>This works fine as long as the shared library is used. When the static version is used, none of the static objects get included into the final program (because they aren't referenced directly) and thus their functionality isn't available.</p>
  
  <p>Is there a way to force gcc to include all static objects from a library when linking?</p>
  
  <p>The library is Open Source and I could modify it, if that helps.</p>