locked
(C++ newbie) how to reference another WinRT C++ project through with header and library (as opposed to .winmd)

    Question

  • First I should say I have only theorical knowledge of c++, never done multi (Visual studio) projects project before.

    That said WinRT made me want to have another go at C++! 

    I'm trying to play with DirectX.

    However I'd like to partition my project into multiple... project!

    (A directX part, a data part, etc...)

    One problem I have, if you look at the metro sample, the DirectX samples, the utility class there DirectXBase, BasicShapes, BasicCamera, etc.... they are not "public ref class" (only "ref class") because they can't be exported as public meta data, due to unsupported public fields, such as "ComPtr<ID3D11Texture2D>".

     

    Yet I'd like to make another WinRT C++ project and call those class in the project!
    In my DirectX project I have creaded a D3DImageRenderer (which renders DirectX to an image, thanks to http://jeremiahmorrill.com/

    In the (XAML) project which utilize the DirectX class I have add the project reference to the DirectX project and modified the include path to point the DirectX project

    Then in MainPage.xaml.cpp I added:

    #include "D3DImageRenderer.h"
    
    MainPage::MainPage()
    {
        InitializeComponent();
    
        {
            auto ir = ref new D3DImageRenderer();
        }
    }
    
    

    When I try to compile that I got plenty of error..... (below)

    Short summary: how could I just #include and use my ref class from one project to the next (without using the winmd meta data as they are public ref class)?

    error:

    1>------ Build started: Project: Application1, Configuration: Debug Win32 ------
    1>Build started 1/25/2012 10:49:29 PM.
    1>GetInstalledSDKLocations:
    1>  Searching for SDKs targeting "Windows, 8.0".
    1>ResolveSDKReferences:
    1>    Reading SDK manifest file "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0\ExtensionSDKs\Microsoft.VCLibs\11.0\SDKManifest.xml".
    1>    Targeted configuration and architecture "Debug|x86"
    1>    Could not find "FrameworkIdentity" attribute "FrameworkIdentity-Debug-x86" in the SDK manifest. 
    1>    Found "FrameworkIdentity" attribute "Name = Microsoft.VCLibs.110.Debug, MinVersion = 11.0.0.0" in the SDK manifest.
    1>    Found "APPX" location attribute ".\AppX\Debug\x86\Microsoft.VCLibs.x86.Debug.11.appx" in the SDK manifest.
    1>ExpandSDKReferences:
    1>  Expanding SDK Reference "Microsoft.VCLibs, Version=11.0" from "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0\ExtensionSDKs\Microsoft.VCLibs\11.0\".
    1>  Adding reference assembly "References\CommonConfiguration\Neutral\platform.winmd".
    1>InitializeBuildStatus:
    1>  Touching "Debug\Application1.unsuccessfulbuild".
    1>MarkupCompilePass1:
    1>  (Out) GeneratedCodeFiles: ''
    1>  (Out) GeneratedXamlFiles: ''
    1>  (Out) ClCompile: 'App.xaml.cpp;MainPage.xaml.cpp;pch.cpp'
    1>  (Out) Compile: ''
    1>ClCompile:
    1>  All outputs are up-to-date.
    1>  MainPage.xaml.cpp
    1>c:\program files (x86)\windows kits\8.0\include\winrt\inspectable.h(110): error C2872: 'TrustLevel' : ambiguous symbol
    1>          could be 'c:\program files (x86)\windows kits\8.0\include\winrt\inspectable.h(76) : TrustLevel'
    1>          or       'c:\program files (x86)\microsoft visual studio 11.0\vc\lib\platform.winmd : Platform::TrustLevel'
    1>c:\program files (x86)\windows kits\8.0\include\winrt\activation.h(81): error C2872: 'IActivationFactory' : ambiguous symbol
    1>          could be 'c:\program files (x86)\windows kits\8.0\include\winrt\activation.h(45) : Platform::IActivationFactory IActivationFactory'
    1>          or       'c:\program files (x86)\microsoft visual studio 11.0\vc\lib\platform.winmd : Platform::IActivationFactory'
    1>c:\program files (x86)\windows kits\8.0\include\winrt\activation.h(81): error C3699: '*' : cannot use this indirection on type 'IActivationFactory'
    1>          compiler replacing '*' with '^' to continue parsing
    1>c:\program files (x86)\windows kits\8.0\include\winrt\activation.h(89): error C2371: 'IActivationFactory' : redefinition; different basic types
    1>          c:\program files (x86)\windows kits\8.0\include\winrt\activation.h(45) : see declaration of 'IActivationFactory'
    1>c:\program files (x86)\windows kits\8.0\include\winrt\roapi.h(53): error C2872: 'IActivationFactory' : ambiguous symbol
    1>          could be 'c:\program files (x86)\windows kits\8.0\include\winrt\activation.h(89) : IActivationFactory'
    1>          or       'c:\program files (x86)\microsoft visual studio 11.0\vc\lib\platform.winmd : Platform::IActivationFactory'
    1>c:\program files (x86)\windows kits\8.0\include\winrt\wrl\implements.h(1426): error C2872: 'TrustLevel' : ambiguous symbol
    1>          could be 'c:\program files (x86)\windows kits\8.0\include\winrt\inspectable.h(76) : TrustLevel'
    1>          or       'c:\program files (x86)\microsoft visual studio 11.0\vc\lib\platform.winmd : Platform::TrustLevel'
    1>          c:\program files (x86)\windows kits\8.0\include\winrt\wrl\implements.h(1464) : see reference to class template instantiation 'Microsoft::WRL::Details::RuntimeClass<ILst,RuntimeClassFlagsT,false,true>' being compiled
    1>c:\program files (x86)\windows kits\8.0\include\winrt\wrl\implements.h(1531): error C2872: 'TrustLevel' : ambiguous symbol
    1>          could be 'c:\program files (x86)\windows kits\8.0\include\winrt\inspectable.h(76) : TrustLevel'
    1>          or       'c:\program files (x86)\microsoft visual studio 11.0\vc\lib\platform.winmd : Platform::TrustLevel'
    1>          c:\program files (x86)\windows kits\8.0\include\winrt\wrl\implements.h(1570) : see reference to class template instantiation 'Microsoft::WRL::Details::RuntimeClass<ILst,RuntimeClassFlagsT,true,true>' being compiled
    1>c:\program files (x86)\windows kits\8.0\include\winrt\wrl\module.h(77): error C2872: 'TrustLevel' : ambiguous symbol
    1>          could be 'c:\program files (x86)\windows kits\8.0\include\winrt\inspectable.h(76) : TrustLevel'
    1>          or       'c:\program files (x86)\microsoft visual studio 11.0\vc\lib\platform.winmd : Platform::TrustLevel'
    1>c:\program files (x86)\windows kits\8.0\include\winrt\wrl\module.h(271): error C2872: 'IActivationFactory' : ambiguous symbol
    1>          could be 'c:\program files (x86)\windows kits\8.0\include\winrt\activation.h(89) : IActivationFactory'
    1>          or       'c:\program files (x86)\microsoft visual studio 11.0\vc\lib\platform.winmd : Platform::IActivationFactory'
    1>c:\program files (x86)\windows kits\8.0\include\winrt\wrl\module.h(326): error C2872: 'IActivationFactory' : ambiguous symbol
    1>          could be 'c:\program files (x86)\windows kits\8.0\include\winrt\activation.h(89) : IActivationFactory'
    1>          or       'c:\program files (x86)\microsoft visual studio 11.0\vc\lib\platform.winmd : Platform::IActivationFactory'
    1>c:\program files (x86)\windows kits\8.0\include\winrt\wrl\module.h(1032): error C2872: 'IActivationFactory' : ambiguous symbol
    1>          could be 'c:\program files (x86)\windows kits\8.0\include\winrt\activation.h(89) : IActivationFactory'
    1>          or       'c:\program files (x86)\microsoft visual studio 11.0\vc\lib\platform.winmd : Platform::IActivationFactory'
    1>          c:\program files (x86)\windows kits\8.0\include\winrt\wrl\module.h(1144) : see reference to class template instantiation 'Microsoft::WRL::ActivationFactory<I0,I1,I2,cacheFlagValue>' being compiled
    1>c:\program files (x86)\windows kits\8.0\include\winrt\wrl\module.h(1120): error C2872: 'TrustLevel' : ambiguous symbol
    1>          could be 'c:\program files (x86)\windows kits\8.0\include\winrt\inspectable.h(76) : TrustLevel'
    1>          or       'c:\program files (x86)\microsoft visual studio 11.0\vc\lib\platform.winmd : Platform::TrustLevel'
    1>c:\program files (x86)\windows kits\8.0\include\winrt\wrl\module.h(1403): error C2872: 'IActivationFactory' : ambiguous symbol
    1>          could be 'c:\program files (x86)\windows kits\8.0\include\winrt\activation.h(89) : IActivationFactory'
    1>          or       'c:\program files (x86)\microsoft visual studio 11.0\vc\lib\platform.winmd : Platform::IActivationFactory'
    1>          c:\program files (x86)\windows kits\8.0\include\winrt\wrl\module.h(1450) : see reference to class template instantiation 'Microsoft::WRL::Module<InProc,ModuleT>' being compiled
    1>c:\program files (x86)\windows kits\8.0\include\winrt\wrl\module.h(1457): error C2872: 'IActivationFactory' : ambiguous symbol
    1>          could be 'c:\program files (x86)\windows kits\8.0\include\winrt\activation.h(89) : IActivationFactory'
    1>          or       'c:\program files (x86)\microsoft visual studio 11.0\vc\lib\platform.winmd : Platform::IActivationFactory'
    1>          c:\program files (x86)\windows kits\8.0\include\winrt\wrl\module.h(1466) : see reference to class template instantiation 'Microsoft::WRL::Module<InProcDisableCaching,ModuleT>' being compiled
    1>c:\program files (x86)\windows kits\8.0\include\winrt\wrl\module.h(1717): error C2872: 'IActivationFactory' : ambiguous symbol
    1>          could be 'c:\program files (x86)\windows kits\8.0\include\winrt\activation.h(89) : IActivationFactory'
    1>          or       'c:\program files (x86)\microsoft visual studio 11.0\vc\lib\platform.winmd : Platform::IActivationFactory'
    1>          c:\program files (x86)\windows kits\8.0\include\winrt\wrl\module.h(1740) : see reference to class template instantiation 'Microsoft::WRL::Module<OutOfProcDisableCaching,ModuleT>' being compiled
    1>
    1>Build FAILED.
    1>
    1>Time Elapsed 00:00:01.97
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    


     

    Thursday, January 26, 2012 6:51 AM

Answers

  • Regarding your component / project architecture, I would recommend reviewing this talk as Herb does an overview of the rules regarding what you can use internally in your components as well as what you can expose across the ABI layer for WinRT callers / callees. Specifically ~12min into the recording is where that subject starts.

    Using the Windows Runtime from C++
    TOOL-532T
    Speakers: Herb Sutter

    Your XAML app would reference the .winmd of your WinRT DLL if it is not a part of your solution. If it is a part of the same solution, you can select it from the list of solution projects in the Add Reference dialog.

     

    Thanks,

    -David

     

     

     

    • Marked as answer by Bob_Bao Tuesday, February 7, 2012 6:39 AM
    Tuesday, January 31, 2012 12:15 AM
    Moderator