title: Looking for a Static Link Order tool on Linux
body: <p>Are there any decent tools to determine the optimal static link order with g++ under Linux?  I'm familiar with the general issues, including (if necessary) the use of repeated references to a single library or --start-group and --end-group to resolve circular dependencies, but what I'd like, if possible, is a tool that will take a bunch of .a files and spit out a good static link order for them, repeating libraries if necessary, while keeping the repetition to a minimum.</p>
  
  <p>Background: I'm working on a project with around 800K lines of inherited c++ code, and trying to refactor it into smaller, more manageable chunks.  Some of the existing files are huge monoliths - today I've been wrestling with a single 34K line .h file that defined 113 classes and structs.  Many of the classes were defined almost entirely inline in the .h file.  As I split this up into smaller chunks, and migrate some of the implementation code into .cpp files, the required link order on Linux keeps changing.  That's probably because every library that included the .h file used to compile its own implementation of whatever classes it needed, and now they are having to link to a common implementation in a single library file.  Long-term we'll probably reorganize some of the classes into different libraries, and break some of the dependency chains, but right now the dependencies are pretty tangled, and I'm trying to minimize the perturbations to the code that could change behavior.  I'd prefer not to have to keep manually figuring out the right link order every time it changes.  Suggestions?</p>