locked
StaticLibrary( Window store apps) cannot use Windows::Media or Windows::Device

    Question

  • I created a project for StaticLibrary( Window store apps) to enumerate audio devices and capture audio.

    But VS2012 always notifies :  "Windows" has no member "Devices" and  Windows" has no member "Media".

    How can I resolve these?

    Tuesday, November 20, 2012 12:34 PM

Answers

  • Hello,

    Using WinRT objects in a static library requires that you use the /ZW switch. By default the /ZW switch is not enabled in a static library. Once you fillip this switch you will see a warning in the output window. While it might be possible to combine use WinRT objects from the a static library it is not recommended. The recommendation is to use a WinRT component as long as the interfaces will not be very "chatty". 

    Please take a look at this post for more information.

    http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/b9c8a6d0-d6e8-4300-ab04-ef42a332d92f

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Tuesday, November 20, 2012 11:02 PM
    Moderator
  • Note you can suppress the /ZW warning from the librarian by going to Configuration Properties \ Librarian \ Command Line and then add to the "Additional Options" field

    /IGNORE:4264

    We do this with DirectXTK which builds as a static library using /ZW for use with Windows Store (and Windows phone 8) apps.

    Just be sure you understand that the static library in question can only be used by applications that use /ZW, and that the static library can only consume WinRT APIs and not provide them.

    See this thread for some technical details.



    Wednesday, November 21, 2012 12:16 AM

All replies

  • Hello,

    Using WinRT objects in a static library requires that you use the /ZW switch. By default the /ZW switch is not enabled in a static library. Once you fillip this switch you will see a warning in the output window. While it might be possible to combine use WinRT objects from the a static library it is not recommended. The recommendation is to use a WinRT component as long as the interfaces will not be very "chatty". 

    Please take a look at this post for more information.

    http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/b9c8a6d0-d6e8-4300-ab04-ef42a332d92f

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Tuesday, November 20, 2012 11:02 PM
    Moderator
  • Note you can suppress the /ZW warning from the librarian by going to Configuration Properties \ Librarian \ Command Line and then add to the "Additional Options" field

    /IGNORE:4264

    We do this with DirectXTK which builds as a static library using /ZW for use with Windows Store (and Windows phone 8) apps.

    Just be sure you understand that the static library in question can only be used by applications that use /ZW, and that the static library can only consume WinRT APIs and not provide them.

    See this thread for some technical details.



    Wednesday, November 21, 2012 12:16 AM
  • Thanks, it's great help.

    Wednesday, November 21, 2012 2:21 AM
  • thanks your noitification. I will think about it carefully
    Wednesday, November 21, 2012 2:24 AM