title: Porting cross-platform C++ libraries to Windows Phone 8 platform
body: <p>I've searched the web and StackOverflow a lot, but can't seem to find a definitive answer to my following questions.</p>
  
  <p><strong>Context:</strong></p>
  
  <p>I am looking to port a group of C++ helper libraries for use with the Windows Phone 8 (WP8) platform. Historically, these libraries are built as static libs (rather than DLLs).</p>
  
  <p>I have successfully written the WP8-specific code, so that the libraries are compatible and building against ARM, using the APIs available to WP8 (using the WP API QuickStart doc as a reference point). Only one of the libraries (e.g. Lib1) requires consumption of the WinRT extensions (the /ZW flag), due to having to replace the classic Win32 Thread calls with WinRT's ThreadPool.</p>
  
  <p>When building Lib1, I get the following warning: 
  Warning 1 warning LNK4264: archiving object file compiled with /ZW into a static library; note that when authoring Windows Runtime types it is not recommended to link with a static library that contains Windows Runtime metadata.</p>
  
  <p>— searching for this warning, I found <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh771041.aspx">this article</a>, stating:
  "If you consume a static library that creates public ref classes, public interface classes, or public value classes, the linker raises this warning. You can safely ignore the warning if the static library is not producing Windows Runtime components that are consumed outside the library itself. Public components in a static library will compile but will not activate at run time. Any Windows Runtime component that's intended for consumption by other components or apps must be implemented in a dynamic-link library (DLL)."</p>
  
  <p>In Lib1, ClassA contains the functions using WinRT ThreadPool calls. ClassA functions are called by ClassB, and they simply return regular HANDLEs and DWORDs to ClassB. </p>
  
  <p><strong>Code example:</strong></p>
  
  <pre><code>// ClassA.cpp
  HANDLE WINAPI ClassA::CreateThread(/* Params that are usually passed to Win32 CreateThread */)
  {
      // Do WinRTThreadPool stuff to create WorkItem
      auto workItem = ref new Windows::System::Threading::WorkItemHandler([=](Windows::Foundation::IAsyncAction^)
      // More code that eventually results in a Win32 Handle
  
      return handle;
  }
  
  // ClassB.cpp
  Handle handle = ClassA::CreateThread(/* Params that are usually passed to Win32 CreateThread */);
  </code></pre>
  
  <p>ClassA's functions will only ever be called by ClassB, from within Lib1, and ClassB can then be used by the application linking Lib1.</p>
  
  <p><strong>Finally, to my questions:</strong></p>
  
  <ol>
  <li><p>Can the C++ libraries that do <em>not</em> consume WinRT extensions (/ZW),
  when built as static libs, be used by Windows Phone 8 applications?</p></li>
  <li><p>Can the C++ library (Lib1) that <em>does</em> consume WinRT extensions
  (/ZW), when built as a static lib, be used by Windows Phone 8
  applications, despite the warning?</p></li>
  <li><p>If the answer is no to either question, will I have to create WinRT
  Component wrappers for all of the classes in the respective library,
  like <a href="http://www.silverlightshow.net/items/Windows-Phone-8-Native-Code-Support.aspx">this article</a> demonstrates with the Mandelbrot Algorithm? Or is there something else I'm missing?</p></li>
  </ol>
  
  <p>Thanks in advance for any input you can provide.</p>