c++ - How to reference Windows Runtime classes in a Static Library? -


i new programming in c++ on universal windows platform , have quick question: created project of static library (universal windows) in visual studio 2015 couldn't use windows runtime classes such windows::ui::core::corewindow in project.

i guess need add include directives or references libraries couldn't find information that. tried search msdn found 2 pages 2 headers mentioned namespace default , collections.

does know how reference windows runtime classes in static library?

you need build project /zw option allow consuming windows runtime extension in uwp static library:

  1. right click on project solution explorer
  2. click properties
  3. select c/c++ -> general
  4. set "consume windows runtime extension" "yes(/zw)"
  5. click ok

after applying option, references windows runtime extensions appear under references of project , can use windows runtime classes.

however, may see linker warning while building library:

debug\pch.obj : warning lnk4264: archiving object file compiled /zw static library; note when authoring windows runtime types not recommended link static library contains windows runtime metadata if using linker released before vs 2015 update 2

i tested scenario , worked fine in debug mode, however, i'm not sure if best way since /zw option off default unlike other types of uwp projects.

msdn:

you can use native c++ static library in uwp project, there restrictions , limitations aware of. start reading topic static libraries in c++/cx. can access native code in static library uwp app, it's not recommended create public ref types in such static library. if compile static library /zw option, librarian (actually linker in disguise) warns:

maybe should consider wrapping code in windows runtime component or uwp dll instead.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -