I've searched the web and StackOverflow a lot, but can't seem to find a definitive answer to my following questions.
Context:
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).
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.
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.
— searching for this warning, I found this article, 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)."
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.
Code example:
// 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 */);
ClassA's functions will only ever be called by ClassB, from within Lib1, and ClassB can then be used by the application linking Lib1.
Finally, to my questions:
Can the C++ libraries that do not consume WinRT extensions (/ZW), when built as static libs, be used by Windows Phone 8 applications?
Can the C++ library (Lib1) that does consume WinRT extensions (/ZW), when built as a static lib, be used by Windows Phone 8 applications, despite the warning?
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 this article demonstrates with the Mandelbrot Algorithm? Or is there something else I'm missing?
Thanks in advance for any input you can provide.