title: Static objects are not being linked in a static lib in VC 2010. How do I force a link?
body: <p>I have a static factory that relies on a static member of itself to register the class into the factory system.</p>
  
  <pre><code>class Foo_A_Maker : public FooFactory&lt;Foo, const std::string &amp;&gt;
  {
  private:
      // Register this as a type using a static instance of itself.
      // This is really the only time it is created. That's why the
      // constructor is private.
      Foo_A_Maker() : FooFactory("Foo_A") {}
      static const Foo_A_Maker registerThis;
  
  public:
      virtual std::shared_ptr&lt;Foo&gt; MakeProduct(const std::string&amp; params) const;
  };
  </code></pre>
  
  <p>This has worked for years in all my projects, but now I have added it to a static library. In the static library, the ctor is never called and the object never registers. If I put this code in the exe project it works again. I have determined that this is not linking by introducing a link time error.</p>
  
  <p>Am I missing something? Can I force a link? And if I use this across compilation boundaries can the EXE project add its own factories?</p>
  
  <p>Thanks all.</p>