{"id":17325,"date":"2017-10-23T17:32:17","date_gmt":"2017-10-24T00:32:17","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/?p=17325"},"modified":"2019-02-18T17:48:15","modified_gmt":"2019-02-18T17:48:15","slug":"vcpkg-using-multiple-enlistments","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/vcpkg-using-multiple-enlistments\/","title":{"rendered":"Vcpkg: Using multiple enlistments to handle multiple versions of a library"},"content":{"rendered":"<p>Vcpkg allows you to <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/vcpkg-a-tool-to-acquire-and-build-c-open-source-libraries-on-windows\/\">acquire and build 3<sup>rd<\/sup> party libraries on Windows<\/a>. Once cloned, the vcpkg directory (enlistment) provides a stable set of libraries that are all compatible and based on the latest published version of these libraries. Occasionally, you may need different versions of the same library. By design, you can\u2019t have two different versions of the same library in the same enlistment; instead, you need to create and work with multiple enlistments.<\/p>\n<h4>Creating multiple enlistments<\/h4>\n<h6>1) Clone the git repository<\/h6>\n<p>To create multiple enlistments, just reclone the GitHub repo on a different location on your machine:<\/p>\n<p><font face=\"Consolas\">git clone https:\/\/github.com\/Microsoft\/vcpkg.git<\/font><\/p>\n<p>By default, the master branch of vcpkg presents the latest version of libraries. If you need an older version, browse the file history of the library to see if the version you are looking for is available. The control file should display the version history.<\/p>\n<h6>2) Find a specific version<\/h6>\n<p>For example, imagine you want to use OpenCV, but not the 3.3.0.4, but instead the 3.2.0 version:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/clip_image00235.jpg\"><img decoding=\"async\" width=\"595\" height=\"189\" title=\"clip_image002\" style=\"border: 0px currentcolor\" alt=\"clip_image002\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/clip_image002_thumb23.jpg\" border=\"0\"><\/a><\/p>\n<p>Once you have identified the version, use the &lt;&gt; button to navigate the repo at this point in time. <\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/clip_image00421.jpg\"><img decoding=\"async\" width=\"583\" height=\"136\" title=\"clip_image004\" style=\"border: 0px currentcolor\" alt=\"clip_image004\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/clip_image004_thumb16.jpg\" border=\"0\"><\/a><\/p>\n<h6>3) Clone the repo for a specific label\/hash<\/h6>\n<p>You\u2019re now ready to clone the repo for OpenCV version 3.2.0 from February 8<sup>th<\/sup>, 2017. Note: it is important that all the libraries you are going to use came from the same label\/hash. By cloning the entire repo from that label\/hash the dependents libraries will be compatible with the version of the lib you selected.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/clip_image00615.jpg\"><img decoding=\"async\" width=\"546\" height=\"82\" title=\"clip_image006\" style=\"border: 0px currentcolor\" alt=\"clip_image006\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/clip_image006_thumb12.jpg\" border=\"0\"><\/a><\/p>\n<p>Click on the commit hash, and then copy the \u201ccomplete\u201d commit hash:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/clip_image00818.jpg\"><img decoding=\"async\" width=\"539\" height=\"101\" title=\"clip_image008\" style=\"border: 0px currentcolor\" alt=\"clip_image008\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/clip_image008_thumb14.jpg\" border=\"0\"><\/a><\/p>\n<p>This is the one to use for your new enlistment, via the git checkout command:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/clip_image01010.jpg\"><img decoding=\"async\" width=\"543\" height=\"138\" title=\"clip_image010\" style=\"border: 0px currentcolor\" alt=\"clip_image010\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/clip_image010_thumb10.jpg\" border=\"0\"><\/a><\/p>\n<h6>4) build vcpkg for a specific label\/hash<\/h6>\n<p>Don\u2019t forget to build vcpkg via the bootstrap file running:<\/p>\n<p><font face=\"Consolas\">bootstrap-vcpkg.bat<\/font><\/p>\n<p>You\u2019re now ready to build OpenCV 3.2.0 with the dependencies corresponding to this version. <\/p>\n<h4>Using multiple enlistments<\/h4>\n<p>Now you\u2019re ready to use your new\/specific version of your libraries. To switch between enlistments for your project, we provide two approaches:<\/p>\n<p>\u00b7 Reference the enlistment via the integrate project command<\/p>\n<p>\u00b7 Use the Export command to package the libraries in a NuGet Package (or in a raw or zip format)<\/p>\n<h6>a) Run the vcpkg integrate project command:<\/h6>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/clip_image0126.jpg\"><img decoding=\"async\" width=\"563\" height=\"54\" title=\"clip_image012\" style=\"border: 0px currentcolor\" alt=\"clip_image012\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/clip_image012_thumb6.jpg\" border=\"0\"><\/a><\/p>\n<p>As mentioned in the comment, go to your project and add a reference to this NuGet Package. The NuGet Package contains only a \u201c<b><strong><strong><u>link<\/u><\/strong><\/strong><\/b>\u201d to your new enlistment. Your project is now linked with the libraries present in the second enlistment. <\/p>\n<h6>b) Run vcpkg export &lt;mylibs&gt; &#8211;nuget<\/h6>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/clip_image0143.jpg\"><img decoding=\"async\" width=\"569\" height=\"159\" title=\"clip_image014\" style=\"border: 0px currentcolor\" alt=\"clip_image014\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/clip_image014_thumb3.jpg\" border=\"0\"><\/a><\/p>\n<p>Once again, the command specifies how to use the NuGet generated package. In this second case, the <b>NuGet Package <strong><u>contains the binary of the library, the .lib, the .h and the .pdb<\/u><\/strong><\/b>. Of course, it also contains all the dependencies needed by the library.<\/p>\n<p>We really value your feedback as an essential source of improvement. Please let us know if you have issues with this tool or usage scenario by opening an issue on GitHub or sending us an email at <a>vcpkg@microsoft.com<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vcpkg allows you to acquire and build 3rd party libraries on Windows. Once cloned, the vcpkg directory (enlistment) provides a stable set of libraries that are all compatible and based on the latest published version of these libraries. Occasionally, you may need different versions of the same library. By design, you can\u2019t have two different [&hellip;]<\/p>\n","protected":false},"author":316,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[272],"tags":[271,273],"class_list":["post-17325","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vcpkg","tag-cpp","tag-vcpkg"],"acf":[],"blog_post_summary":"<p>Vcpkg allows you to acquire and build 3rd party libraries on Windows. Once cloned, the vcpkg directory (enlistment) provides a stable set of libraries that are all compatible and based on the latest published version of these libraries. Occasionally, you may need different versions of the same library. By design, you can\u2019t have two different [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/17325","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/316"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=17325"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/17325\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=17325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=17325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=17325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}