vcpkg下载mysql库_vcpkg:用于 Windows、Linux 和 macOS 的 C++ 包管理器

vcpkg是一个用于Windows、Linux和macOS的C++包管理器,简化第三方库的安装。它支持开源和专有库,与Visual Studio 2015、2017、2019兼容,并提供命令行接口。vcpkg通过下载源代码或二进制文件,使用C或C++编译器为项目安装和管理库。
摘要由CSDN通过智能技术生成

vcpkg:用于 Windows、Linux 和 macOS 的 C++ 包管理器vcpkg: a C++ package manager for Windows, Linux, and macOS

12/11/2020

本文内容

Vcpkg 是适用于 C 和 C++ 库的跨平台命令行包管理器。vcpkg is a cross-platform command-line package manager for C and C++ libraries. 它简化了 Windows、Linux 和 macOS 上第三方库的购置与安装。It simplifies the acquisition and installation of third-party libraries on Windows, Linux, and macOS. 如果项目要使用第三方库,建议通过 vcpkg 来安装它们。If your project uses third-party libraries, we recommend that you use vcpkg to install them. vcpkg 同时支持开源和专有库。vcpkg supports both open-source and proprietary libraries. 已测试 vcpkg Windows 目录中所有库与 Visual Studio 2015、Visual Studio 2017 及 Visual Studio 2019 的兼容性。All libraries in the vcpkg Windows catalog have been tested for compatibility with Visual Studio 2015, Visual Studio 2017, and Visual Studio 2019. 在 Windows 和 Linux/macOS 目录之间,vcpkg 现已支持数千个库。Between the Windows and Linux/macOS catalogs, vcpkg now supports thousands of libraries. C++ 社区会不断向两个目录添加更多的库。The C++ community adds more libraries to both catalogs on an ongoing basis.

如何获取和使用 vcpkgHow to get and use vcpkg

可通过从 vcpkg GitHub 存储库创建本地克隆来安装 vcpkghttps://github.com/Microsoft/vcpkg。Install vcpkg by making a local clone from its GitHub repo https://github.com/Microsoft/vcpkg. 然后运行 vcpkg-bootstrapper 脚本对其进行设置。Then run the vcpkg-bootstrapper script to set it up. 有关详细的安装说明,请参阅安装 vcpkg。For detailed installation instructions, see Install vcpkg. 若要将 vcpkg 与 Visual Studio 或 Visual Studio Code 开发环境集成,请参阅集成 vcpkg。To integrate vcpkg with your Visual Studio or Visual Studio Code development environment, see Integrate vcpkg. 若要使用 vcpkg 来安装或更新库,请参阅使用 vcpkg 管理库。Then, to use vcpkg to install or update a library, see Manage libraries with vcpkg. 有关 vcpkg 命令的详细信息,请参阅 vcpkg 命令行参考。For more information about vcpkg commands, see vcpkg command-line reference.

Vcpkg 的工作原理How vcpkg works

Vcpkg 是 GitHub 上提供的开放源代码项目。The vcpkg project is open-source, available on GitHub. Vcpkg 存储库的克隆或本地副本包含 vcpkg 可执行文件和目录,这是描述库及其选项的包的列表 。A clone or local copy of the vcpkg repo contains the vcpkg executable and a catalog, a list of packages that describe a library and its options. 每个包都包含一个或多个端口,还包括有关如何从源获取和生成库的信息,或为特定目标环境下载二进制版本的信息。Each package includes one or more ports, information about how to obtain and build the library from sources, or download a binary version, for a specific target environment. 使用 vcpkg 安装库时,它会使用包和端口信息在 vcpkg 目录的子目录中下载并生成库的本地副本,供你使用。When you use vcpkg to install a library, it uses the package and port information to download and produce a local copy of the library in a subdirectory of the vcpkg directory, ready for you to use.

当库可用于源表单时,vcpkg 会下载源而不是二进制文件。When a library is available in source form, vcpkg downloads sources instead of binaries. 它使用最新版 C 或 C++ 编译器和可以找到的工具编译这些源代码。It compiles those sources using the most recent version of the C or C++ compiler and tools that it can find. 在 C++ ABI 兼容性方面,有一点至关重要,即你的应用程序代码以及你所使用的任何库都应由同一编译器的相同版本进行编译。For C++ ABI compatibility, it's important that both your application code and any libraries you use are compiled by the same version of the same compiler. 通过 vcpkg 可以消除或最大程度减少不匹配二进制文件的存在风险及它可能造成的问题。By using vcpkg, you eliminate or at least greatly reduce the potential for mismatched binaries and the problems they can cause. 对于使用特定编译器版本的标准化团队而言,可让一位成员使用 vcpkg 下载源并编译一组二进制文件。In teams that standardize on a specific version of a compiler, one team member can use vcpkg to download sources and compile a set of binaries. 让团队中的每位成员都下载和生成公用库是一种效率较低的做法。It's inefficient to make everyone on a team download and build common libraries. 可让一位团队成员使用 vcpkg export 命令来创建二进制文件和标头的通用 zip 文件,或者创建一个 NuGet 包。One team member can use the vcpkg export command to create a common zip file of the binaries and headers, or a NuGet package. 然后,可以轻松地将它与其他团队成员共享。Then, it's easy to share it with other team members.

为不同的目标自定义 vcpkg 实例Customize vcpkg instances for different targets

可以在计算机上克隆 vcpkg 的多个副本或实例,并针对特定用途自定义每个副本或实例。You can clone multiple copies, or instances, of vcpkg on your machine, and customize each one for specific purposes. 例如,除了在公共目录中找到的内容外,还可以安装不同的库或不同版本的库。In each instance, you can install different libraries, or even different versions of libraries than the ones found in the public catalog. 可使用首选的编译器选项设置每个实例,以生成自定义库集合。Each instance may be set to produce a custom collection of libraries, using your preferred compiler options. 每个实例都是一个自包含的环境,它自身的 vcpkg.exe 副本仅可在自己的层次结构中运行。Every instance is a self-contained environment with its own copy of vcpkg.exe that operates only on its own hierarchy. vcpkg 不会被添加到任何环境变量中,并且在 Windows 注册表或 Visual Studio 上也没有依赖项。vcpkg isn't added to any environment variables, and has no dependency on the Windows Registry or Visual Studio.

你还可以创建一个包含端口集合中的专用库的 vcpkg 克隆。You can also create a vcpkg clone that has private libraries in the ports collection. 可添加一个可下载预生成的二进制文件和标头的端口。You can add a port that downloads your prebuilt binaries and headers. 然后,编写一个仅将这些文件复制到首选位置的 portfile.cmake 文件。Then, write a portfile.cmake file that simply copies those files to the preferred location.

vcpkg 文件夹层次结构The vcpkg folder hierarchy

所有 vcpkg 功能和数据都自包含在实例的单独目录层次结构中。All vcpkg functionality and data is self-contained in a single directory hierarchy per instance. 没有注册表设置或环境变量。There are no registry settings or environment variables. 可以在一台计算机上设置任意数量的 vcpkg 实例,它们彼此互不干扰。You can have any number of instances of vcpkg on a machine, and they won't interfere with each other.

vcpkg 实例的内容如下:The contents of a vcpkg instance are:

buildtrees - 包含从中生成每个库的源的子文件夹。buildtrees - Contains subfolders of sources from which each library is built.

docs - 文档和示例。docs - documentation and examples.

downloads - 所有已下载的工具或源的缓存副本。downloads - Cached copies of any downloaded tools or sources. 运行安装命令时,vcpkg 会首先搜索此处。vcpkg searches here first when you run the install command.

installed - 包含每个已安装库的标头和二进制文件。installed - Contains the headers and binaries for each installed library. 与 Visual Studio 集成时,实质上是相当于告知它将此文件夹添加到其搜索路径。When you integrate with Visual Studio, you're essentially telling it add this folder to its search paths.

packages - 在不同的安装之间用于暂存的内部文件夹。packages - Internal folder for staging between installs.

ports - 用于描述每个库的目录、版本和下载位置的文件。ports - Files that describe each library in the catalog, its version, and where to download it. 如有需要,可添加自己的端口。You can add your own ports if needed.

scripts - 由 vcpkg 使用的脚本(CMake、PowerShell)。scripts - Scripts (CMake, PowerShell) used by vcpkg.

toolsrc - vcpkg 和相关组件的 C++ 源代码。toolsrc - C++ source code for vcpkg and related components.

triplets - 包含每个受支持目标平台(如 x86-windows 或 x64-uwp)的设置。triplets - Contains the settings for each supported target platform (for example, x86-windows or x64-uwp).

遥测技术Telemetry

Vcpkg 收集使用数据,以帮助我们改进你的体验。vcpkg collects usage data in order to help us improve your experience. Microsoft 收集的数据是匿名的。The data collected by Microsoft is anonymous. 通过使用 -disableMetrics 选项重新运行 bootstrap-vcpkg.bat 或 bootstrap-vcpkg.sh 脚本,可以选择退出遥测 。You can opt-out of telemetry by re-running the bootstrap-vcpkg.bat or bootstrap-vcpkg.sh script using the -disableMetrics option. 或者,将 --disable-metrics 选项传递到命令行上的 vcpkg。Or, pass the --disable-metrics option to vcpkg on the command line. 还可通过设置 VCPKG_DISABLE_METRICS 环境变量来禁用指标。You can also disable metrics by setting the VCPKG_DISABLE_METRICS environment variable.

发送关于 vcpkg 的反馈Send feedback about vcpkg

使用 vcpkg contact --survey 命令向 Microsoft 发送有关 vcpkg 的反馈,包括 Bug 报告和功能建议。Use the vcpkg contact --survey command to send feedback to Microsoft about vcpkg, including bug reports and suggestions for features. 有关详细信息,请参阅 vcpkg 命令行参考。

另请参阅See also

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值