VS2012 Error C1107

12,152

Solution 1

I don't understand what the problem you have, so

  1. If you don't want to code against WinRT just set "Consume..." to false and the issue will be gone
  2. If you want to code against WinRT you should perform an additional step: go to General and set Windows Store App Support to true

Solution 2

To create a C++/CX Desktop application:

In C/C++ -> General project properties, set Consume Windows Runtime Extension to Yes

In the same tab enter these to your Additional #using Directories enter the directories containing the windows.winmd and platform.winmd files. For me, with VS2017, that is:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\store\references;
C:\Program Files (x86)\Windows Kits\10\UnionMetadata;
C:\Program Files (x86)\Windows Kits\10\References\Windows.Foundation.UniversalApiContract\2.0.0.0;
C:\Program Files (x86)\Windows Kits\10\References\Windows.Foundation.FoundationContract\2.0.0.0

Then call RoInitialize or use a WinRT main style function (to remove the warning C4447 about main threading):

using namespace Platform;

int main(Array<String^>^ args) ....

References:
Using C++/CX in Desktop apps,
Calling Windows 10 APIs from a desktop application

Share:
12,152
aCuria
Author by

aCuria

Updated on June 04, 2022

Comments

  • aCuria
    aCuria almost 2 years

    I am getting the following error:

    fatal error C1107: could not find assembly 'platform.winmd': please specify the assembly search path using /AI or by setting the LIBPATH environment variable
    

    Steps to reproduce

    0) Create a new empty project

    1) C/C++ > General > Consume Windows Runtime Extension > YES

    2) C/C++ > Code Generation > Enable Minimal Rebuild > No

    3) Add a source file *.cpp, file can be blank

    4) Attempt to compile

    I tried to manually compare and change the project settings to match that in some sample code but nothing seems to work.

  • Mark
    Mark about 9 years
    What flag is associated with that option? I have a Cmake that creates the vs project so how can I enable that?
  • Yoav Schwartz
    Yoav Schwartz almost 9 years
    @IonescuRobert, that's /ZW
  • jorgen
    jorgen almost 5 years
    This seems to be the correct option if you want your app to keep targeting Windows. Note: Had to append TargetPlatformVersion to UnionMetadata to find windows.winmd: C:\Program Files (x86)\Windows Kits\10\UnionMetadata\$(TargetPlatformVersion)