title: CATCH Unit Testing Suite with Visual Studio 2010
body: <p>As far as I understand it, I can simply place <code>catch.hpp</code> into my project directory, add it to the project, and then start writing tests. I'm running into a few, or 11 to be exact, linker errors once I try using some of the macros outlined in the <a href="https://github.com/philsquared/Catch/blob/master/docs/tutorial.md" rel="noreferrer">tutorial</a>.</p>
  
  <pre><code>#include "catch.hpp"
  
  unsigned int Factorial( unsigned int number ) {
      return number &lt;= 1 ? number : Factorial(number-1)*number;
  }
  
  TEST_CASE( "Factorials are computed", "[factorial]" ) {
      REQUIRE( Factorial(1) == 1 );
      REQUIRE( Factorial(2) == 2 );
      REQUIRE( Factorial(3) == 6 );
      REQUIRE( Factorial(10) == 3628800 );
  }
  </code></pre>
  
  <p>I'm able to create a single file out of the first example and compile it with g++, but when I just paste the same code into my VS2010 project and then try to run it, I run into the linker errors. Unfortunately I'm not familiar enough with C++ at this point to decode the errors myself, and after taking a look at the single file <a href="https://github.com/philsquared/Catch/blob/master/single_include/catch.hpp" rel="noreferrer">here</a>, I was unable to discern the issue.</p>
  
  <pre><code>Error   1   error LNK2019: unresolved external symbol "public: __thiscall Catch::AutoReg::AutoReg(void (__cdecl*)(void),struct Catch::SourceLineInfo const &amp;,struct Catch::NameAndDesc const &amp;)" (??0AutoReg@Catch@@QAE@P6AXXZABUSourceLineInfo@1@ABUNameAndDesc@1@@Z) referenced in function "void __cdecl `anonymous namespace'::`dynamic initializer for 'autoRegistrar27''(void)" (??__EautoRegistrar27@?A0x3911e331@@YAXXZ)    C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1   1   FirstCPPApplication
  Error   2   error LNK2019: unresolved external symbol "public: __thiscall Catch::ExpressionResultBuilder::ExpressionResultBuilder(enum Catch::ResultWas::OfType)" (??0ExpressionResultBuilder@Catch@@QAE@W4OfType@ResultWas@1@@Z) referenced in function __catch$?____C_A_T_C_H____T_E_S_T____27@@YAXXZ$0   C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1   1   FirstCPPApplication
  Error   3   error LNK2019: unresolved external symbol "class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; __cdecl Catch::translateActiveException(void)" (?translateActiveException@Catch@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function __catch$?____C_A_T_C_H____T_E_S_T____27@@YAXXZ$0   C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1   1   FirstCPPApplication
  Error   4   error LNK2019: unresolved external symbol "public: class Catch::ExpressionResultBuilder &amp; __thiscall Catch::ExpressionResultBuilder::endExpression(enum Catch::ResultDisposition::Flags)" (?endExpression@ExpressionResultBuilder@Catch@@QAEAAV12@W4Flags@ResultDisposition@2@@Z) referenced in function "void __cdecl ____C_A_T_C_H____T_E_S_T____27(void)" (?____C_A_T_C_H____T_E_S_T____27@@YAXXZ)   C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1   1   FirstCPPApplication
  Error   5   error LNK2019: unresolved external symbol "public: __thiscall Catch::AssertionInfo::AssertionInfo(class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;,struct Catch::SourceLineInfo const &amp;,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;,enum Catch::ResultDisposition::Flags)" (??0AssertionInfo@Catch@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABUSourceLineInfo@1@0W4Flags@ResultDisposition@1@@Z) referenced in function "void __cdecl ____C_A_T_C_H____T_E_S_T____27(void)" (?____C_A_T_C_H____T_E_S_T____27@@YAXXZ) C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1   1   FirstCPPApplication
  Error   6   error LNK2019: unresolved external symbol "struct Catch::IContext &amp; __cdecl Catch::getCurrentContext(void)" (?getCurrentContext@Catch@@YAAAUIContext@1@XZ) referenced in function "struct Catch::IResultCapture &amp; __cdecl Catch::getResultCapture(void)" (?getResultCapture@Catch@@YAAAUIResultCapture@1@XZ)    C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1   1   FirstCPPApplication
  Error   7   error LNK2019: unresolved external symbol "public: class Catch::ExpressionResultBuilder &amp; __thiscall Catch::ExpressionResultBuilder::setOp(class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;)" (?setOp@ExpressionResultBuilder@Catch@@QAEAAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "private: class Catch::ExpressionResultBuilder &amp; __thiscall Catch::ExpressionLhs&lt;int const &amp;&gt;::captureExpression&lt;0,int&gt;(int const &amp;)" (??$captureExpression@$0A@H@?$ExpressionLhs@ABH@Catch@@AAEAAVExpressionResultBuilder@1@ABH@Z) C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1   1   FirstCPPApplication
  Error   8   error LNK2019: unresolved external symbol "public: class Catch::ExpressionResultBuilder &amp; __thiscall Catch::ExpressionResultBuilder::setRhs(class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;)" (?setRhs@ExpressionResultBuilder@Catch@@QAEAAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "private: class Catch::ExpressionResultBuilder &amp; __thiscall Catch::ExpressionLhs&lt;int const &amp;&gt;::captureExpression&lt;0,int&gt;(int const &amp;)" (??$captureExpression@$0A@H@?$ExpressionLhs@ABH@Catch@@AAEAAVExpressionResultBuilder@1@ABH@Z)   C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1   1   FirstCPPApplication
  Error   9   error LNK2019: unresolved external symbol "public: class Catch::ExpressionResultBuilder &amp; __thiscall Catch::ExpressionResultBuilder::setLhs(class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;)" (?setLhs@ExpressionResultBuilder@Catch@@QAEAAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "private: class Catch::ExpressionResultBuilder &amp; __thiscall Catch::ExpressionLhs&lt;int const &amp;&gt;::captureExpression&lt;0,int&gt;(int const &amp;)" (??$captureExpression@$0A@H@?$ExpressionLhs@ABH@Catch@@AAEAAVExpressionResultBuilder@1@ABH@Z)   C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1   1   FirstCPPApplication
  Error   10  error LNK2019: unresolved external symbol "public: class Catch::ExpressionResultBuilder &amp; __thiscall Catch::ExpressionResultBuilder::setResultType(bool)" (?setResultType@ExpressionResultBuilder@Catch@@QAEAAV12@_N@Z) referenced in function "private: class Catch::ExpressionResultBuilder &amp; __thiscall Catch::ExpressionLhs&lt;int const &amp;&gt;::captureExpression&lt;0,int&gt;(int const &amp;)" (??$captureExpression@$0A@H@?$ExpressionLhs@ABH@Catch@@AAEAAVExpressionResultBuilder@1@ABH@Z)  C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1   1   FirstCPPApplication
  Error   11  error LNK2019: unresolved external symbol "public: __thiscall Catch::AutoReg::~AutoReg(void)" (??1AutoReg@Catch@@QAE@XZ) referenced in function "void __cdecl `anonymous namespace'::`dynamic atexit destructor for 'autoRegistrar27''(void)" (??__FautoRegistrar27@?A0x3911e331@@YAXXZ)    C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\FirstCPPApplication\FirstCPPApplication.obj 1   1   FirstCPPApplication
  Error   12  error LNK1120: 11 unresolved externals  C:\Users\Mark\documents\visual studio 2010\Projects\FirstCPPApplication\Debug\FirstCPPApplication.exe   FirstCPPApplication
  </code></pre>