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:
- right click on project solution explorer
- click properties
- select c/c++ -> general
- set "consume windows runtime extension" "yes(/zw)"
- 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
Post a Comment