title: Force library linking with Qt and google test
body: <p>I'm trying to write a test suit for my Qt(c++) application using google test, the main problem is that my application consists of one main program and various shared libs. Everything was working just fine, until I tried to do some code coverage using gcov/lcov (which don't operate on dynamic libs), so I modified all my .pro file to have a static lib compilation using :</p>
  
  <pre><code>
  CONFIG += staticlib create_prl
  QMAKE_LFLAGS += -static
  LIBS += ../../Libs/lib*.a
  </code></pre>
  
  <p>The problem is that google test test application is something like this:</p>
  
  <pre><code>
  
  int main(int argc, char **argv) {
  
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
  }
  
  </code></pre>
  
  <p>so it detects the linkage at runtime, which means that when I compile the test application here is no warning or whatever that indicate a problem, and when running the test application it execute 0 test because it doesn't found any.</p>
  
  <p>my solution (quit annoying one) is to define in each class which will be used for test a phony public static member and do an operation for the main test application on it:</p>
  
  <pre>
  <code>
  class SETTINGS_TESTS_SHARED_EXPORT SettingsTests: public testing::Test {
  
  public:
   SettingsTests();
   virtual ~SettingsTests();
  
   static bool dummy;
  protected:
   virtual void SetUp();
   virtual void TearDown();
  
  private:
   Settings* _setting0;
   Settings* _setting1;
   Settings* _setting2;
  };
  </code>
  </pre>
  
  <pre><code>
  
  using namespace MBI::SETTINGS;
  using namespace MBI::TESTS;
  
  int main(int argc, char **argv) {
  
    SettingsTests::dummy = true;
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
  }
  </code></pre>
  
  <p>so I can force the linkage of that lib on my application.</p>
  
  <p>I have also found the option -u to do something like that in gcc but doesn't seem to work. have anyone have a way to force static library linking if no symbol can be detected in compile time ?</p>