title: Linker error - linking two "application" type projects in order to use Google Test
body: <p>I am trying to test a function with Google Test.</p>
  
  <p>It seems that everything is set up correctly, and it builds and executes fine without gtest... (There is a bit of complexity in the code, so I cannot list all the source files here, but without adding gtest, the files are linking properly, and running as they should).</p>
  
  <p>It is an application type project. It has a number of library dependencies... irrelevant.</p>
  
  <p>The test project is added as a separate project to the solution. It has the tested project as a dependency. The .h file of the test project only points to the gtest... The .cpp (not main, which is the standard InitGoogleTest main) adds its own header file, the header file of the tested project, and has the test shown below.</p>
  
  <p>There is a TestedProject.lib created automatically, when the project builds, even though it is an application. I have added TestedProject.lib as a library dependency to the TestProject (in Link).</p>
  
  <pre><code>Class x
  {
  public:
    x(){}    // I didn't really need this, I only added the class so I have access to 
    ~x(){};  // non-class methods with gtest - but it still doesn't work
    bool myFunction(std::string a, double b, bool c);  
  };
  </code></pre>
  
  <p>implementation:</p>
  
  <pre><code>bool x::myFunction(std::string a, double b, bool c)
  {
    // implementation
    return false;
  }
  
  somewhere_else
  {
    x x_instance;
    y = x_instance.myFunction("a", 1, false);   // works, all builds, executes, life is great
  }
  </code></pre>
  
  <p>Add unit test:</p>
  
  <pre><code>class TheTest : public ::testing::Test
  {
  protected:
      x x_instance;
  };
  
  TEST_F(TheTest, Fail)
  {
      EXPECT_FALSE(x_instance.myFunction("a", 1, false));     
  }
  </code></pre>
  
  <p>Doesn't build. Link error (modified, like the sample code above, with simplified names, I hope I didn't mess up content)</p>
  
  <pre><code>Error   2   error LNK2019: unresolved external symbol 
  "public: bool __thiscall x::myFunction(class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,double,bool)" 
  (?myFunction@x@@QAE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@00000NNNN_N1@Z) 
  referenced in function "private: virtual void __thiscall TheTest_Fail_Test::TestBody(void)" 
  (?TestBody@TheTest_Fail_Test@@EAEXXZ)   C:\path\file.obj
  </code></pre>
  
  <p>I have done this before - solved link errors - wrote a couple of tests with Google test - but I can't see anything missing.</p>
  
  <p>As a test, I wrote a little</p>
  
  <p>int test(){return 4;}
  in the header file, in the class declaration...</p>
  
  <p>and then, replaced the test with
  EXPECT_EQ(x.test(), 4);</p>
  
  <p>It worked. Great. But that would mean to have all the tested code in a single file, a cpp or something... which is simply unreasonable. There are a few files in this Application project. </p>
  
  <p>How can I fix this issue ? How can I make Google Test link and test with a class with a header and an implementation file ? When that header/implementation is in a different project, of "Application" type ?</p>
  
  <p>The only similar issue I have found, so far: <a href="https://stackoverflow.com/questions/2507595/c-linking-issue-on-visual-studio-2008-when-crosslinking-different-projects-on">C++ linking issue on Visual Studio 2008 when crosslinking different projects on same solution</a></p>
  
  <p>Please, help me find a solution.</p>