{"id":11535,"date":"2016-11-01T16:25:45","date_gmt":"2016-11-01T23:25:45","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/?p=11535"},"modified":"2019-02-18T18:04:35","modified_gmt":"2019-02-18T18:04:35","slug":"vcpkg-updates-static-linking-is-now-available","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/vcpkg-updates-static-linking-is-now-available\/","title":{"rendered":"Vcpkg updates: Static linking is now available"},"content":{"rendered":"<p><strong>One month ago, we <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/vcpkg-a-tool-to-acquire-and-build-c-open-source-libraries-on-windows\/\">announced the availability of Vcpkg<\/a><\/strong><strong> a command line tool to easily acquire and build open source C++ lib and consume it in Visual Studio 2015. The initial release provided only dynamic link libraries, but we heard your feedback, and <\/strong>we are pleased to announce <a href=\"https:\/\/github.com\/Microsoft\/vcpkg\">static linking support with Vcpkg<\/a>.<\/p>\n<p>To generate static libraries, use one of the triplets: x86-windows-static, or x64-windows-static<\/p>\n<p>For example, to build zlib statically for x86 use:<\/p>\n<pre class=\"code\">vcpkg install zlib:x86-windows-static<\/pre>\n<p>The library will be installed in the following folder:\u00a0 <strong>vcpkg\\installed\\x86-windows-static<\/strong><\/p>\n<h5>Using static libraries<\/h5>\n<p><em><span style=\"color: #999999\"><strong>Updated on 11\/4:<\/strong> to clarify \/MT usage\u00a0and provide guidance how to override auto-detection of triplets<\/span><\/em><\/p>\n<p>We currently deploy a set of built-in triplets that will build static libraries against the static CRT (\/MT in Visual Studio): x86-windows-static, x64-windows-static, etc.<\/p>\n<p><strong>In Visual Studio,<\/strong> you can override the auto-detected triplet (which will default to DLLs) using the MSBuild properties &#8220;VcpkgTriplet&#8221; and &#8220;VcpkgEnabled&#8221;. For larger solutions, <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/669zx6zc.aspx\">property sheets<\/a> are a great way to manage these settings\nExample:<\/p>\n<pre>\u00a0&lt;PropertyGroup Label=\"Globals\"&gt;\n &lt;!-- .... --&gt;\n &lt;VcpkgTriplet Condition=\"'$(Platform)'=='Win32'\"&gt;x86-windows-static&lt;\/VcpkgTriplet&gt;\n &lt;VcpkgTriplet Condition=\"'$(Platform)'=='x64'\"&gt;x64-windows-static&lt;\/VcpkgTriplet&gt;\n&lt;\/PropertyGroup&gt;<\/pre>\n<p><strong>In CMake<\/strong>, you can override the auto-detected DLL triplet using `-DVCPKG_TARGET_TRIPLET=x86-windows-static` along with the normal toolchain argument. For example:<\/p>\n<pre class=\"code\">cmake .. -DCMAKE_TOOLCHAIN_FILE=...\/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x86-windows-static<\/pre>\n<p>Note again that all libraries in the *-windows-static triplets are linked against the static CRT (\/MT or \/MTd), so you will need to change your CMAKE_CXX_FLAGS (see <a href=\"http:\/\/stackoverflow.com\/questions\/14172856\/cmake-compile-with-mt-instead-of-md\">http:\/\/stackoverflow.com\/questions\/14172856\/cmake-compile-with-mt-instead-of-md<\/a>).<\/p>\n<h5>Community contributions<\/h5>\n<p>We really want to say thanks to the community. We started with 20 libraries in the catalog, and the community contributed an additional 60+ more lib, <b>for a total of more than 90 libraries [<a href=\"https:\/\/github.com\/Microsoft\/vcpkg\/tree\/master\/ports\">see the complete list here<\/a><\/b><b>]<\/b> The tempo is amazing with almost one new library being added each day: you guys really rock! We collected very good feedback, and many interesting suggestions as well as many requests to add more libraries. Thanks for every contribution and comment, that\u2019s the way we want this project to succeed: by being a real community driven effort.<\/p>\n<p>If you need a specific library, please create an issue identifying the lib you want, don\u2019t hesitate to be precise on the version asked, the source location\u2026 To see the list of libraries asked so far, see the <a href=\"https:\/\/github.com\/Microsoft\/vcpkg\/issues?utf8=%E2%9C%93&amp;q=label%3A%22new%20port%20request%22%20\">issues list tagged with \u201cnew port request<\/a>\u201d. Once the issue is created, the community can jump on your ask and create the right port file. Or if you are already familiar with building the library, please make a Pull Request with your port file and the associated patch file if needed.<\/p>\n<h5>We have updated the documentation<\/h5>\n<p>We improved the port file creation topics see example #2 \u201cPackage a remote project\u201d in <a href=\"https:\/\/github.com\/Microsoft\/\">example.md<\/a>\u00a0 and a <a href=\"https:\/\/github.com\/Microsoft\/\">patch file example<\/a> to help you create and maintain the port file collection more easily.<\/p>\n<p>With static linking we have now reached an important milestone, we are currently planning the next milestone in our roadmap, and this is the right time to share your suggestions and hope for this project. Create an issue on GitHub [ <a href=\"https:\/\/github.com\/Microsoft\/vcpkg\">https:\/\/github.com\/Microsoft\/vcpkg<\/a> ] and engage the conversation.<\/p>\n<p>See you soon on the GitHub repo, for any question you can contact us at <a>vcpkg@microsoft.com<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One month ago, we announced the availability of Vcpkg a command line tool to easily acquire and build open source C++ lib and consume it in Visual Studio 2015. The initial release provided only dynamic link libraries, but we heard your feedback, and we are pleased to announce static linking support with Vcpkg. To generate [&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":[270,272],"tags":[351,271,190,273],"class_list":["post-11535","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-announcement","category-vcpkg","tag-build-libraries-on-windows","tag-cpp","tag-libraries","tag-vcpkg"],"acf":[],"blog_post_summary":"<p>One month ago, we announced the availability of Vcpkg a command line tool to easily acquire and build open source C++ lib and consume it in Visual Studio 2015. The initial release provided only dynamic link libraries, but we heard your feedback, and we are pleased to announce static linking support with Vcpkg. To generate [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/11535","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=11535"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/11535\/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=11535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=11535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=11535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}