Search code examples
c++armdirectxdirectxtk

Why is CoCreateInstanceFromApp missing from an ARM build over an x64 build?


This question does not already have an answer
I know what an unresolved external symbol means - I'm asking specifically why when building as ARM the DirectX functions are missing for my project. When I build my DirectX project for Raspberry Pi I get the below link errors. Why is CoCreateInstFromApp missing only for the ARM build?

The Microsoft documentation on CoCreateInstanceFromApp implies it should simply be present in any Windows executable - this is in fact what I see when building x86 or x64 versions of the same project. It ought to be present, since DirectX does support ARM architecture - or have I missed something?

The project is including d3d11.lib & dxgi.lib, which I presumed it would pick up from the right directory - but get no specific errors about those libraries. The project is C++ in Visual Studio 2017 Pro v15.8.7.

Redacted link error:

DirectXTK_ARM.lib : error LNK2019: unresolved external symbol __imp_CoCreateInstanceFromApp referenced in function "long __cdecl CoCreateInstance ...

DirectXTK_ARM.lib : error LNK2019: unresolved external symbol __imp_PropVariantClear ....


More info, if required:

I have altered this Desktop Duplication sample from Microsoft to do a screen-shot instead of duplication, and thus removed the window code and used DirectXTK for saving the file. This works great on my desktop and on a Minnowboard (x64 Win10 IoT). But if I try and compile for Raspberry PI (ARM) it fails with the link error:

DirectXTK_ARM.lib(WICTextureLoader.obj) : error LNK2019: unresolved external symbol __imp_CoCreateInstanceFromApp referenced in function "long __cdecl CoCreateInstance(struct _GUID const &,struct IUnknown *,unsigned long,struct _GUID const &,void * *)" (?CoCreateInstance@@YAJABU_GUID@@PAUIUnknown@@K0PAPAX@Z)

DirectXTK_ARM.lib(WICTextureLoader.obj) : error LNK2019: unresolved external symbol __imp_PropVariantClear referenced in function "long __cdecl `anonymous namespace'::CreateTextureFromWIC(struct ID3D11Device *,struct ID3D11DeviceContext *,struct IWICBitmapFrameDecode *,unsigned int,enum D3D11_USAGE,unsigned int,unsigned int,unsigned int,unsigned int,struct ID3D11Resource * *,struct ID3D11ShaderResourceView * *)" (?CreateTextureFromWIC@?A0x2b71c33d@@YAJPAUID3D11Device@@PAUID3D11DeviceContext@@PAUIWICBitmapFrameDecode@@IW4D3D11_USAGE@@IIIIPAPAUID3D11Resource@@PAPAUID3D11ShaderResourceView@@@Z) 1


Solution

  • CoCreateInstance and PropVariantClear are part of ole32.lib.

    UWP apps should link with the umbrella WindowsApp.lib, but you can also link to umbrella mincore.lib for IoT apps.