title: Using WRL for C++/CX functions - linker error
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix">What is an undefined reference/unresolved external symbol error and how do I fix it?</a>  </p>
  </blockquote>
  
  
  
  <p>I'm trying to make WinRT library that is not using CX extension. I need to get name of package, roaming data folder, etc.. I wrote some wrapper, but when I'm linking this library to executable project, I get linker error</p>
  
  <pre><code>error LNK2019: unresolved external symbol _WindowsCreateStringReference@16 referenced in function "private: void __thiscall Microsoft::WRL::Wrappers::HStringReference::CreateReference(wchar_t const *,unsigned int,unsigned int)" (?CreateReference@HStringReference@Wrappers@WRL@Microsoft@@AAEXPB_WII@Z)
  error LNK2019: unresolved external symbol _WindowsDeleteString@4 referenced in function "public: __thiscall Microsoft::WRL::Wrappers::HStringReference::~HStringReference(void)" (??1HStringReference@Wrappers@WRL@Microsoft@@QAE@XZ)
  error LNK2019: unresolved external symbol _WindowsGetStringRawBuffer@8 referenced in function "long __cdecl aponialib::winrt::GetFullName(class std::basic_string&lt;wchar_t,struct std::char_traits&lt;wchar_t&gt;,class std::allocator&lt;wchar_t&gt; &gt; &amp;)" (?GetFullName@winrt@aponialib@@YAJAAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z)
  error LNK2019: unresolved external symbol __imp__RoGetActivationFactory@12 referenced in function "long __cdecl Windows::Foundation::GetActivationFactory&lt;struct ABI::Windows::Storage::IApplicationDataStatics&gt;(struct HSTRING__ *,struct ABI::Windows::Storage::IApplicationDataStatics * *)" (??$GetActivationFactory@UIApplicationDataStatics@Storage@Windows@ABI@@@Foundation@Windows@@YAJPAUHSTRING__@@PAPAUIApplicationDataStatics@Storage@1ABI@@@Z)
  </code></pre>
  
  <p>this is package name wrapper</p>
  
  <pre><code>// including in .h
  #include &lt;windows.h&gt;
  #include &lt;string&gt;
  #include &lt;Strsafe.h&gt;
  #include &lt;Winstring.h&gt;
  
  #include &lt;windows.storage.h&gt;
  #include &lt;Windows.ApplicationModel.h&gt;
  #include &lt;windows.Foundation.h&gt;
  #include &lt;wrl/client.h&gt;
  #include &lt;wrl/wrappers/corewrappers.h&gt;
  
  //...
  
  HRESULT GetFullName(std::wstring &amp;fullName)
  {
      HRESULT hr;
      Microsoft::WRL::ComPtr&lt;ABI::Windows::ApplicationModel::IPackageStatics&gt; packageStatics;
  
      hr = Windows::Foundation::GetActivationFactory(Microsoft::WRL::Wrappers::HStringReference(RuntimeClass_Windows_ApplicationModel_Package).Get(), &amp;packageStatics);
      if (FAILED(hr))
          return hr;
  
      Microsoft::WRL::ComPtr&lt;ABI::Windows::ApplicationModel::IPackage&gt; package;
      hr = packageStatics-&gt;get_Current(&amp;package);
      if (FAILED(hr))
          return hr;
  
      Microsoft::WRL::ComPtr&lt;ABI::Windows::ApplicationModel::IPackageId&gt; packageId;
      hr = package-&gt;get_Id(&amp;packageId);
      if (FAILED(hr))
          return hr;
  
      HSTRING name;
      hr = packageId-&gt;get_FullName(&amp;name);
      if (FAILED(hr))
          return hr;
  
      UINT32 length;
      PCWSTR value = WindowsGetStringRawBuffer(name, &amp;length);
      fullName = value;
      WindowsDeleteString(name);
      return S_OK;
  }
  </code></pre>
  
  <p>Maybe I don't get WRL and I'm using it wrong.</p>
  
  <p>Thank you for your help :)
  Tomas</p>