Coder Social home page Coder Social logo

microsoft / vcpkg Goto Github PK

View Code? Open in Web Editor NEW
21.5K 428.0 6.0K 68.72 MB

C++ Library Manager for Windows, Linux, and MacOS

License: MIT License

CMake 72.38% PowerShell 20.44% Python 2.73% Batchfile 0.08% Shell 3.54% Qt Script 0.20% Nix 0.11% Dockerfile 0.25% C++ 0.27%
vcpkg visual-studio libraries windows cpp package-manager packages c cplusplus cmake

vcpkg's Introduction

Vcpkg: Overview

中文总览 Español 한국어 Français Tiếng Việt

Vcpkg helps you manage C and C++ libraries on Windows, Linux and MacOS. This tool and ecosystem are constantly evolving, and we always appreciate contributions!

If you've never used vcpkg before, or if you're trying to figure out how to use vcpkg, check out our Getting Started section for how to start using vcpkg.

For short description of available commands, once you've installed vcpkg, you can run vcpkg help, or vcpkg help [command] for command-specific help.

Table of Contents

Getting Started

First, follow the quick start guide for either Windows, or macOS and Linux, depending on what you're using.

For more information, see Installing and Using Packages. If a library you need is not present in the vcpkg catalog, you can open an issue on the GitHub repo where the vcpkg team and community can see it, and potentially add the port to vcpkg.

After you've gotten vcpkg installed and working, you may wish to add tab completion to your shell.

Quick Start: Windows

Prerequisites:

  • Windows 7 or newer
  • Git
  • Visual Studio 2015 Update 3 or greater with the English language pack

First, download and bootstrap vcpkg itself; it can be installed anywhere, but generally we recommend using vcpkg as a submodule so the consuming repo can stay self-contained. Alternatively, vcpkg can be installed globally; we recommend somewhere like C:\src\vcpkg or C:\dev\vcpkg, since otherwise you may run into path issues for some port build systems.

> git clone https://github.com/microsoft/vcpkg
> .\vcpkg\bootstrap-vcpkg.bat

To install the libraries for your project, run:

> .\vcpkg\vcpkg install [packages to install]

Note: This will install x86 libraries by default. To install x64, run:

> .\vcpkg\vcpkg install [package name]:x64-windows

Or

> .\vcpkg\vcpkg install [packages to install] --triplet=x64-windows

You can also search for the libraries you need with the search subcommand:

> .\vcpkg\vcpkg search [search term]

In order to use vcpkg with Visual Studio, run the following command (may require administrator elevation):

> .\vcpkg\vcpkg integrate install

After this, you can now create a New non-CMake Project (or open an existing one). All installed libraries are immediately ready to be #include'd and used in your project without additional configuration.

If you're using CMake with Visual Studio, continue here.

In order to use vcpkg with CMake outside of an IDE, you can use the toolchain file:

> cmake -B [build directory] -S . "-DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake"
> cmake --build [build directory]

With CMake, you will still need to find_package and the like to use the libraries. Check out the CMake section for more information, including on using CMake with an IDE.

Quick Start: Unix

Prerequisites for Linux:

Prerequisites for macOS:

First, download and bootstrap vcpkg itself; it can be installed anywhere, but generally we recommend using vcpkg as a submodule.

$ git clone https://github.com/microsoft/vcpkg
$ ./vcpkg/bootstrap-vcpkg.sh

To install the libraries for your project, run:

$ ./vcpkg/vcpkg install [packages to install]

You can also search for the libraries you need with the search subcommand:

$ ./vcpkg/vcpkg search [search term]

In order to use vcpkg with CMake, you can use the toolchain file:

$ cmake -B [build directory] -S . "-DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake"
$ cmake --build [build directory]

With CMake, you will still need to find_package and the like to use the libraries. Check out the CMake section for more information on how best to use vcpkg with CMake, and CMake Tools for VSCode.

Installing Linux Developer Tools

Across the different distros of Linux, there are different packages you'll need to install:

  • Debian, Ubuntu, popOS, and other Debian-based distributions:
$ sudo apt-get update
$ sudo apt-get install build-essential tar curl zip unzip
  • CentOS
$ sudo yum install centos-release-scl
$ sudo yum install devtoolset-7
$ scl enable devtoolset-7 bash

For any other distributions, make sure you're installing g++ 6 or above. If you want to add instructions for your specific distro, please open a PR!

Installing macOS Developer Tools

On macOS, the only thing you should need to do is run the following in your terminal:

$ xcode-select --install

Then follow along with the prompts in the windows that comes up.

You'll then be able to bootstrap vcpkg along with the quick start guide

Using vcpkg with CMake

Visual Studio Code with CMake Tools

Adding the following to your workspace settings.json will make CMake Tools automatically use vcpkg for libraries:

{
  "cmake.configureSettings": {
    "CMAKE_TOOLCHAIN_FILE": "[vcpkg root]/scripts/buildsystems/vcpkg.cmake"
  }
}

Vcpkg with Visual Studio CMake Projects

Open the CMake Settings Editor, and under CMake toolchain file, add the path to the vcpkg toolchain file:

[vcpkg root]/scripts/buildsystems/vcpkg.cmake

Vcpkg with CLion

Vcpkg is integrated in the CLion IDE. For details, see the official documentation.

Vcpkg as a Submodule with CMake

When using vcpkg as a submodule of your project, you can add the following to your CMakeLists.txt before the first project() call, instead of passing CMAKE_TOOLCHAIN_FILE to the cmake invocation.

set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake"
  CACHE STRING "Vcpkg toolchain file")

This will still allow people to not use vcpkg, by passing the CMAKE_TOOLCHAIN_FILE directly, but it will make the configure-build step slightly easier.

Tab-Completion/Auto-Completion

vcpkg supports auto-completion of commands, package names, and options in both powershell and bash. To enable tab-completion in the shell of your choice, run:

> .\vcpkg integrate powershell

or

$ ./vcpkg integrate bash # or zsh

depending on the shell you use, then restart your console.

Examples

See the documentation for specific walkthroughs, including installing and using a package, adding a new package from a zipfile, and adding a new package from a GitHub repo.

Our docs are now also available online at our website https://vcpkg.io/. We really appreciate any and all feedback! You can submit an issue in https://github.com/vcpkg/vcpkg.github.io/issues.

See a 4 minute video demo.

Contributing

Vcpkg is an open source project, and is thus built with your contributions. Here are some ways you can contribute:

Please refer to our Contributing Guide for more details.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or email [email protected] with any additional questions or comments.

License

The code in this repository is licensed under the MIT License. The libraries provided by ports are licensed under the terms of their original authors. Where available, vcpkg places the associated license(s) in the location installed/<triplet>/share/<port>/copyright.

Security

Most ports in vcpkg build the libraries in question using the original build system preferred by the original developers of those libraries, and download source code and build tools from their official distribution locations. For use behind a firewall, the specific access needed will depend on which ports are being installed. If you must install it in an "air gapped" environment, consider installing once in a non-"air gapped" environment, populating an asset cache shared with the otherwise "air gapped" environment.

Telemetry

vcpkg collects usage data in order to help us improve your experience. The data collected by Microsoft is anonymous. You can opt-out of telemetry by

  • running the bootstrap-vcpkg script with -disableMetrics
  • passing --disable-metrics to vcpkg on the command line
  • setting the VCPKG_DISABLE_METRICS environment variable

Read more about vcpkg telemetry at https://learn.microsoft.com/vcpkg/about/privacy.

vcpkg's People

Contributors

adela0814 avatar alexkaratarakis avatar atkawa7 avatar autoantwort avatar billyoneal avatar cenit avatar chausner avatar cheney-w avatar codicodi avatar coryan avatar dg0yt avatar frankxie05 avatar jackboosy avatar jiayuehua avatar jimwang118 avatar jonliu1993 avatar lilywangl avatar lilywangll avatar monicaliu0311 avatar myd7349 avatar nancyli1013 avatar neumann-a avatar phoebehui avatar ras0219 avatar ras0219-msft avatar rastaban avatar rt2code avatar strega-nil avatar thomas1664 avatar vicroms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vcpkg's Issues

How distribute exe tools like protobuf compiler?

vcpkg install return error:

The following EXEs were found in /bin and /debug/bin. EXEs are not valid distribution targets.

    D:/Work/vcpkg/packages/protobuf_x86-windows/bin/protoc.exe

but we need protoc.exe for using protobuf library

Official mechanism to backfill/pin older library versions [was: multiple versions]

Sometimes there is a reason to use a specific older version of a library. Usually, it happens due to API changes the project can't absorb right now or 3rd-party libraries that aren't compatible with the newer version (yet).

Seems like a good idea to allow installation of an older version and maybe even having a few versions installed side-by-side.

integrate install fails after recent commit

Hi, commit 81d6426 causes the integrate install command to fail (or report failure) for me. The check:

Checks::check_exit(fs::exists(system_wide_targets_file), "Error: failed to copy targets file to %s", system_wide_targets_file.string());

in commands_integration.cpp now fails as it appears to be checking for a different file to the one that was XCOPY'd.

Update: the destination file has "ts" appended to it. Playing with xcopy, it seems to be padding/extending/completing the destfile extension with what came from the original file:

C:\>xcopy "C:\test.first.second" "C:\test.third*" /Y >nul

C:\>dir
 Volume in drive C has no label.
 Volume Serial Number is AAAA-AAAA

 Directory of C:\

21/09/2016  18:40               414 test.first.second
21/09/2016  18:40               414 test.thirdd

I assume this behaviour of xcopy is well understood by people who aren't me!

Error installing tiff lib

c:\vcpkg>vcpkg.exe install tiff
-- CURRENT_INSTALLED_DIR=C:/vcpkg/installed/x86-windows
-- DOWNLOADS=C:/vcpkg/downloads
-- CURRENT_PACKAGES_DIR=C:/vcpkg/packages/tiff_x86-windows
-- CURRENT_BUILDTREES_DIR=C:/vcpkg/buildtrees/tiff
-- CURRENT_PORT_DIR=c:/vcpkg/ports/tiff/.
-- Downloading ftp://ftp.remotesensing.org/pub/libtiff/tiff-4.0.6.tar.gz
CMake Error at scripts/cmake/vcpkg_download_distfile.cmake:17 (file):
file DOWNLOAD HASH mismatch

for file: [C:/vcpkg/downloads/tiff-4.0.6.tar.gz]
  expected hash: [d1d2e940dea0b5ad435f21f03d96dd72]
    actual hash: [d41d8cd98f00b204e9800998ecf8427e]
         status: [6;"Couldn't resolve host name"]

Call Stack (most recent call first):
ports/tiff/portfile.cmake:2 (vcpkg_download_distfile)
scripts/ports.cmake:84 (include)

Error: build command failed

Migrate to SHA-512

We currently use MD5 for integrity checking downloads, however this is provably breakable (even if improbable). We should upgrade all hashes to SHA-512 and require it going forward.

FINDSTR line too long when building boost

When building boost, the post-build validation step displays:

-- Performing post-build validation
FINDSTR: Line 552 is too long.
FINDSTR: Line 563 is too long.
FINDSTR: Line 552 is too long.
FINDSTR: Line 563 is too long.
-- Performing post-build validation done

Add MPIR

https://github.com/wbhart/mpir

MPIR is a fork of the GNU Multi Precision library (GMP -- see http://gmplib.org)

MPIR is a library for arbitrary precision arithmetic, operating on signed
integers, rational numbers, and floating point numbers. It has a rich set of
functions, and the functions have a regular interface.

MPIR is designed to be as fast as possible, both for small operands and huge
operands. The speed is achieved by using fullwords as the basic arithmetic
type, by using fast algorithms, with carefully optimized assembly code for the
most common inner loops for lots of CPUs, and by a general emphasis on speed
(instead of simplicity or elegance).

GMP/MPIR is believed to be faster than any other similar library. Its advantage
increases with operand sizes for certain operations, since MPIR in many
cases has asymptotically faster algorithms.

Error updating boost

I tried to update boost from 1.60 to 1.61 using these commands:

vcpkg remove --purge boost:x86-windows 
vcpkg install boost:x86-windows

but the installation failed because of linking errors. The old build directories (1.60) were still there and they probably contained the old files. After removing these directories (buildtrees\boost\x86-windows-rel and buildtrees\boost\x86-windows-dbg) the installation went fine.

Should these directories be removed by the vcpkg remove command?
Is it ok to remove everything in buildtrees\* after installing a package?

Boost picks up site-config, which will break builds

I can't instal boost on my machine (Win10, VS2015 U3) it seems as if the build script expects a g++ compiler.

This is the output from powershell:

-- Building x64-windows-rel
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:14 (message):
Command failed:
C:/xTools/vcpkg/vcpkg/buildtrees/boost/src/boost_1_61_0/b2.exe;--stagedir=C:/xTools/vcpkg/vcpkg/buildtrees/boost/x64-windows-rel/stage;--build-dir=C:/xTools/vcpkg/vcpkg/buildtrees/boost/x64-windows-rel;--toolset=msvc;-j4;-q;--without-python;threading=multi;link=shared;runtime-link=shared;--debug-configuration;address-model=64;variant=release

Working Directory: C:/xTools/vcpkg/vcpkg/buildtrees/boost/src/boost_1_61_0

See logs for more information:

 C:\xTools\vcpkg\vcpkg\buildtrees\boost\build-x64-windows-rel-out.log
 C:\xTools\vcpkg\vcpkg\buildtrees\boost\build-x64-windows-rel-err.log

Call Stack (most recent call first):
ports/boost/portfile.cmake:38 (vcpkg_execute_required_process)
scripts/ports.cmake:84 (include)`

Error: build command failed

And this is the content of C:\xTools\vcpkg\vcpkg\buildtrees\boost\build-x64-windows-rel-out.log

notice: found boost-build.jam at C:/xTools/vcpkg/vcpkg/buildtrees/boost/src/boost_1_61_0/boost-build.jam
notice: loading Boost.Build from C:/xTools/vcpkg/vcpkg/buildtrees/boost/src/boost_1_61_0/tools/build/src
notice: Searching 'C:\WINDOWS' [...] 'C:\xTools\vcpkg\vcpkg\buildtrees\boost\src\boost_1_61_0\tools/build/src' 'C:/xTools/vcpkg/vcpkg/buildtrees/boost/src/boost_1_61_0/tools/build/src/kernel' 'C:/xTools/vcpkg/vcpkg/buildtrees/boost/src/boost_1_61_0/tools/build/src/util' 'C:/xTools/vcpkg/vcpkg/buildtrees/boost/src/boost_1_61_0/tools/build/src/build' 'C:/xTools/vcpkg/vcpkg/buildtrees/boost/src/boost_1_61_0/tools/build/src/tools' 'C:/xTools/vcpkg/vcpkg/buildtrees/boost/src/boost_1_61_0/tools/build/src/contrib' 'C:/xTools/vcpkg/vcpkg/buildtrees/boost/src/boost_1_61_0/tools/build/src/.' for site-config configuration file 'site-config.jam'.
notice: Loading site-config configuration file 'site-config.jam' from 'C:/Users/'.
warning: toolset gcc initialization: can not find tool g++
warning: initialized from C:\Usersl\site-config.jam:1
C:/xTools/vcpkg/vcpkg/buildtrees/boost/src/boost_1_61_0/tools/build/src/tools\gcc.jam:150: in gcc.init from module gcc
error: toolset gcc initialization:
error: no command provided, default command 'g++' not found
error: initialized from C:\Users\site-config.jam:1
C:/xTools/vcpkg/vcpkg/buildtrees/boost/src/boost_1_61_0/tools/build/src/build\toolset.jam:43: in toolset.using from module toolset
C:/xTools/vcpkg/vcpkg/buildtrees/boost/src/boost_1_61_0/tools/build/src/build\project.jam:1052: in using from module project-rules
C:\Users\site-config.jam:1: in modules.load from module site-config
C:/xTools/vcpkg/vcpkg/buildtrees/boost/src/boost_1_61_0/tools/build/src\build-system.jam:249: in load-config from module build-system
C:/xTools/vcpkg/vcpkg/buildtrees/boost/src/boost_1_61_0/tools/build/src\build-system.jam:351: in load-configuration-files from module build-system
C:/xTools/vcpkg/vcpkg/buildtrees/boost/src/boost_1_61_0/tools/build/src\build-system.jam:524: in load from module build-system
C:\xTools\vcpkg\vcpkg\buildtrees\boost\src\boost_1_61_0\tools\build\src/kernel\modules.jam:295: in import from module modules
C:\xTools\vcpkg\vcpkg\buildtrees\boost\src\boost_1_61_0\tools\build\src/kernel/bootstrap.jam:139: in boost-build from module
C:\xTools\vcpkg\vcpkg\buildtrees\boost\src\boost_1_61_0\boost-build.jam:17: in module scope from module

Add Thrift

It would be great to have Apache Thrift in the available list of packages

Add ChakraCore

https://github.com/Microsoft/ChakraCore

ChakraCore is the core part of Chakra, the high-performance JavaScript engine that powers Microsoft Edge and Windows applications written in HTML/CSS/JS. ChakraCore supports Just-in-time (JIT) compilation of JavaScript for x86/x64/ARM, garbage collection, and a wide range of the latest JavaScript features. ChakraCore also supports the JavaScript Runtime (JSRT) APIs, which allows you to easily embed ChakraCore in your applications.

Add libxml2

libxml2 is famous xml library and widely used in C world. http://xmlsoft.org/
If we can use libxml2 by vcpkg, many other xml software will be open to vcpkg.

Add mirror support for `vcpkg_download_distfile`

port files refer directly to URLs of external websites, e.g. for Curl: "https://curl.haxx.se/download/curl-7.48.0.tar.bz2". That is very brittle, in that if that site were to go down, suddenly potentially a lot of programmers can't build their code.

That may be an acceptable trade-off for individual programmers, but for a larger organization having the teams ability to work depend on many external sites may be a deal breaker, unless there was some easy way to (locally?) cache things.

Add Bond

https://microsoft.github.io/bond/

Bond is an open source, cross-platform framework for working with schematized data. It supports cross-language serialization/deserialization and powerful generic mechanisms for efficiently manipulating data.

Note: The bond compiler is written in Haskell. I'm not aware of an official binary release.

Change default triplet

The default triplet is "x86-windows".

Since we mainly develop very memory demanding applications, I build all libraries for x64. This means I always have to use "vcpkg install boost:x64-windows" etc. It would be very convenient to make it possible to let the user set a default triplet that is then used when building any package.

Support static linking with /MT /MTd

Maybe it is already possible, but the docs so far appear to imply code gets compiled into DLLs.

Please also support compiling all code into a .lib with /MT /MTd runtime libraries for those of use who prefer their executables to be self-contained (or document how it is done).

Reconsider cross-platform stance

Saying "we don't want to duplicate the apt-get on Linux" makes a lot of sense as a reason why vcpkg is not cross-platform.

Except, when it comes to managing dependencies, versions, and how to refer to them from your project / CMake, vcpkg and apt-get are not that alike at all. For someone working cross-platform, having to test in different way, instruct their users how to build in different ways etc. is not helpful.

And since vcpkg builds upon CMake, making it cross-platform should at least technically not be hard.

vcpkg appears very well thought out, it be great to take the benefits of this to C++ developers even further.

Find a testing solution

As stated in #41, we should find a proper way to test the portfiles.
An ideal system would be to automatically test new/updated portfiles after each push and ignore those which were untouched.

rapidjson doesn't install

Returns the following error:

CMake error at ports/rapidjson/portfile.cmake:1 (include):
include could not find load file:
winports_common_functions
Call Stack (most recent call first):
scripts/ports.cmake:84 (include)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.