Building a WindowsPhone app that depends on pre-compiled WinRT libraries

Dec 3, 2014 at 11:34 PM
Edited Dec 3, 2014 at 11:42 PM
I'm working on a CMakeLists.txt where we want to generate Windows Phone or store app. We'd like to compile against pre-built libraries, some of whom are WinRT components.

We have a CI build where we generate the .lib, .dll, .pri, .pdb, .manifest and .winmd files for each library.

For example, for one library we end up with these output files:
  • MyLib.dll
  • MyLib.exp
  • MyLib.lib
  • MyLib.manifest
  • MyLib.pri
  • MyLib.winmd
Now in our project we want to register the include and library:
SET(CMAKE_FIND_LIBRARY_PREFIXES "")
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll")
# Bunch of stuff
target_link_libraries(${EXE_NAME} ${MyLib_LIBRARIES})
target_include_directories(${EXE_NAME} PUBLIC
  ${MyLib_INCLUDE_DIRS}
  )
But when running MSBuild it complains about a syntax error finding a symbol that is defined in that library.

How do I register this WinRT dependency in a way that the build will work - so that it knows about the winmd to reference, and where the dll is?
set_target_properties(${EXE_NAME} PROPERTIES VS_WINRT_REFERENCES MyLib)
Dec 5, 2014 at 4:55 PM
I am having the same issue.

Warmest regards, Matt
Coordinator
Dec 5, 2014 at 5:16 PM
Thanks for the report. Let me take a look at the issue and get back to the forum.
Dec 8, 2014 at 7:51 PM
I've been playing around with this and haven't yet found a solution. If I use:
set_target_properties(${EXE_NAME} PROPERTIES VS_WINRT_REFERENCES C:/path/to/MyLib.winmd)
That seems to add the winmd as a reference in the project , but cmake likes unix file separators and VS2013 doesn't, so I need to edit the generated vcxproj file to switch the slashes around.

This does build, but the generated appx won't deploy and running in VS2013 lets me get so far as the splash screen in the emulator but then crashes saying specified module cannot be found.

It looks like the DLLs for the winmd files get loaded and then unloaded:
'my_project.exe' (Win32): Loaded 'U:\SharedData\PhoneTools\AppxLayouts\f0473be1-c557-4f98-a103-4ba9f453b5b0VS.Debug_Win32.Username\MyLib.dll'. Module was built without symbols.
'my_project.exe' (Win32): Unloaded 'U:\SharedData\PhoneTools\AppxLayouts\f0473be1-c557-4f98-a103-4ba9f453b5b0VS.Debug_Win32.Username\MyLib.dll'

Stack trace:
 >COMBASE.DLL!77494385()
 >vccorlib120d_app.dll!Windows::Foundation::Diagnostics::OriginateError(HRESULT error, HSTRING__ * message) Line 211
 >vccorlib120d_app.dll!Platform::Details::ReCreateException(long hrEx) Line 155
 >vccorlib120d_app.dll!__abi_WinRTraiseCOMException(long hr) Line 572
 >my_project.exe!__abi_WinRTraiseException(long __hrArg) Line 1121
 >my_project.exe!__abi_ThrowIfFailed(long __hrArg) Line 97
 >my_project.exe!MyLib::Application::Application()
 >my_project.exe!main::__l3::<lambda>(Windows::UI::Xaml::ApplicationInitializationCallbackParams ^ params) Line 25
 >my_project.exe!Platform::Details::__abi_FunctorCapture<void <lambda>(Windows::UI::Xaml::ApplicationInitializationCallbackParams ^),void,Windows::UI::Xaml::ApplicationInitializationCallbackParams ^>::Invoke(Windows::UI::Xaml::ApplicationInitializationCallbackParams ^ <__args_0>) Line 875
 >my_project.exe!Windows::UI::Xaml::ApplicationInitializationCallback::Invoke(Windows::UI::Xaml::ApplicationInitializationCallbackParams ^ __param0)
 >my_project.exe!Windows::UI::Xaml::ApplicationInitializationCallback::[Windows::UI::Xaml::ApplicationInitializationCallback::__abi_IDelegate]::__abi_Windows_UI_Xaml_ApplicationInitializationCallback___abi_IDelegate____abi_Invoke(Windows::UI::Xaml::ApplicationInitializationCallbackParams ^ __param0)
 >WINDOWS.UI.XAML.DLL!6dcfabda()
 >WINDOWS.UI.XAML.DLL!6dcf908e()
 >TWINAPI.APPCORE.DLL!75390b97()
 >TWINAPI.APPCORE.DLL!75390a0b()
 >SHCORE.DLL!75be027f()
 >NTDLL.DLL!7769c4ab()
 >NTDLL.DLL!7769c475()
Dec 8, 2014 at 9:23 PM
I ran into this: http://stackoverflow.com/questions/19555318/cant-load-winrt-component-unless-i-reference-the-project

Which seems to suggest that if I want to refer to WinRT components that are C++ that I'll need to generate an extension SDK that effectively packages up the dll/pri/pdb/winmd/lib for each arch and config.

I'm hoping I'm wrong and I'm just missing something simple.
Coordinator
Dec 8, 2014 at 9:27 PM
I have a repro and a potential solution. I'm still coding it up, but it should work with your scenario.