Vcpkg updates: Static linking is now available

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 static libraries, use one of the triplets: x86-windows-static, or x64-windows-static

For example, to build zlib statically for x86 use:

vcpkg install zlib:x86-windows-static

The library will be installed in the following folder:  vcpkg\installed\x86-windows-static

Using static libraries

Updated on 11/4: to clarify /MT usage and provide guidance how to override auto-detection of triplets

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.

In Visual Studio, you can override the auto-detected triplet (which will default to DLLs) using the MSBuild properties “VcpkgTriplet” and “VcpkgEnabled”. For larger solutions, property sheets are a great way to manage these settings
Example:

    <PropertyGroup Label="Globals">
        ....
        <VcpkgTriplet>x86-windows-static</VcpkgTriplet>
        <VcpkgEnabled>true</VcpkgEnabled>
    </PropertyGroup>

In CMake, you can override the auto-detected DLL triplet using `-DVCPKG_TARGET_TRIPLET=x86-windows-static` along with the normal toolchain argument. For example:

cmake .. -DCMAKE_TOOLCHAIN_FILE=.../vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x86-windows-static

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 http://stackoverflow.com/questions/14172856/cmake-compile-with-mt-instead-of-md).

Community contributions

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, for a total of more than 90 libraries [see the complete list here] 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’s the way we want this project to succeed: by being a real community driven effort.

If you need a specific library, please create an issue identifying the lib you want, don’t hesitate to be precise on the version asked, the source location… To see the list of libraries asked so far, see the issues list tagged with “new port request”. 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.

We have updated the documentation

We improved the port file creation topics see example #2 “Package a remote project” in example.md  and a patch file example to help you create and maintain the port file collection more easily.

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 [ https://github.com/Microsoft/vcpkg ] and engage the conversation.

See you soon on the GitHub repo, for any question you can contact us at vcpkg@microsoft.com