Install Boost C++ Library Mac
2018-5-15 boost c库的Mac OS 绑定,操作简单,使用方便,以下介绍详细步骤。 博文 来自: 坐着游戏的火箭. Mac下boost的安装与使用 Install and use boost library on Mac 12-04 阅读数 6261 linux系列之常用运维命令整理 11-02 boost全平台编译 06-11 阅读数 4万+. 2019-10-13 Just a note that for Boost 1.67.0, I had to go back to bootstrap.bat gcc instead of mingw.Not sure if that's something in the Boost build system or my setup, but it worked. @BramVanroy, the project setup depends on what you are developing using Boost.Boost is composed of multiple libraries. Welcome to Boost.org! Boost provides free peer-reviewed portable C source libraries. We emphasize libraries that work well with the C Standard Library. Boost libraries are intended to be widely useful, and usable across a broad spectrum of applications. 2019-12-11 Ten Boost libraries are already included in the C Standards Committee's Library Technical Report and will be included in the upcoming revision of the C Standard. More Boost libraries are proposed for the upcoming TR2. Changes in this release. Boost 1.66 includes 3 new libraries (Beast, CallableTraits, Mp11) as well. Install a library on your local machine. After you get the name of a library by using vcpkg search, you use vcpkg install to download the library and compile it. Vcpkg uses the library's portfile in the ports directory. If no triplet is specified, vcpkg will install and compile for.
2020-3-3 Building Boost C Library on a Mac 4 minute read Boost is C library that’s widely used in science software, but it can be a pain to compile yourself, especially on a Mac. The brew formula has given me (and others I’ve talked to) a bit of trouble and it is often better to compile yourself.
-->vcpkg 是用于 C++ 的一种命令行包管理器。vcpkg is a command-line package manager for C++.它极大地简化了 Windows、Linux 和 MacOS 上第三方库的购置与安装。It greatly 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 现已支持超过 1900 个库。Between the Windows and Linux/MacOS catalogs, vcpkg now supports over 1900 libraries.C++ 社区正在不断向两个目录添加更多的库。The C++ community is adding more libraries to both catalogs on an ongoing basis.
简单而灵活Simple yet flexible
仅通过单个命令就能下载源并生成库。With a single command, you can download sources and build a library.vcpkg 本身就是一个开源项目,可通过 GitHub 获取。vcpkg is itself an open-source project, available on GitHub.你可以按照自己喜欢的任何方式自定义你的专用 vcpkg 克隆。It's possible to customize your private vcpkg clones in any way you like.例如,除了在公共目录中找到的内容外,还可以指定不同的库或不同版本的库。For example, specify different libraries, or different versions of libraries than the ones found in the public catalog.一台计算机上可以有多个 vcpkg 克隆。You can have multiple clones of vcpkg on a single machine.每一克隆都可以设置为生成带有你首选的编译开关的自定义库集合。Each one may be set to produce a custom collection of libraries, with your preferred compilation switches.每个克隆都是一个自包含的环境,它自身的 vcpkg.exe 副本仅可在自己的层次结构中运行。Each clone 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.
是源,而不是二进制文件Sources, not binaries
对于 Windows 目录中的库,vcpkg 会下载源,而不是二进制文件1。For libraries in the Windows catalog, vcpkg downloads sources instead of binaries1.它使用可以找到的最新版 Visual Studio 编译这些源代码。It compiles those sources using the most recent version of Visual Studio that it can find.在 C++ 中,有一点至关重要,即你的应用程序代码以及你所使用的任何库应均是由同一编译器和编译器版本编译的。In C++, it's important that both your application code and any libraries you use are compiled by the same compiler, and compiler version.通过 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 are standardized on a specific version of a compiler, one team member can use vcpkg to download sources and compile a set of binaries.他们随后可以使用导出命令将二进制文件和标头进行压缩打包,从而与其他团队成员共享。Then they can use the export command to zip up the binaries and headers for other team members.有关详细信息,请参阅下方的导出已编译二进制文件及标头。For more information, see Export compiled binaries and headers below.
你还可以创建一个包含端口集合中的专用库的 vcpkg 克隆。You can also create a vcpkg clone that has private libraries in the ports collection.添加一个可下载预生成的二进制文件和标头的端口。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.
1 注意:这些源不适用于某些专有库。 在这些情况下,vcpkg 会下载兼容的预生成二进制文件。1Note: sources are unavailable for some proprietary libraries. In these cases, vcpkg downloads compatible prebuilt binaries.
安装Installation
从 GitHub 克隆 vcpkg 存储库:https://github.com/Microsoft/vcpkg。Clone the vcpkg repo from GitHub: https://github.com/Microsoft/vcpkg.可凭喜好下载到任意文件夹位置。You can download to any folder location you prefer.
在根文件夹中运行 bootstrapper:Run the bootstrapper in the root folder:
- bootstrap-vcpkg.bat (Windows)bootstrap-vcpkg.bat (Windows)
- ./bootstrap-vcpkg.sh (Linux、MacOS)./bootstrap-vcpkg.sh (Linux, MacOS)
搜索可用库列表Search the list of available libraries
要查看哪些包可用,请在命令提示符中键入:vcpkg search To see what packages are available, at the command prompt type: vcpkg search
此命令枚举 vcpkg/ports 子文件夹中的控件文件。This command enumerates the control files in the vcpkg/ports subfolders.将出现如下的文件列表:You'll see a listing like this:
可以根据模式筛选,例如 vcpkg search ta:You can filter on a pattern, for example vcpkg search ta:
在本地计算机上安装库Install a library on your local machine
在使用 vcpkg search 获取库的名称后,可使用 vcpkg install 下载库并对其进行编译 。After you get the name of a library by using vcpkg search, you use vcpkg install to download the library and compile it.vcpkg 在端口目录中使用库的端口文件。vcpkg uses the library's portfile in the ports directory.如果未指定三元组,则 vcpkg 将针对目标平台的默认三元组进行安装和编译:x86-windows、x64-linux.cmake 或 x64-osx.cmake。If no triplet is specified, vcpkg will install and compile for the default triplet for the target platform: x86-windows, x64-linux.cmake, or x64-osx.cmake.
对于 Linux 库,vcpkg 取决于本地计算机上安装的 GCC。For Linux libraries, vcpkg depends on gcc being installed on the local machine.在 MacOS 上,vcpkg 使用 Clang。On MacOS, vcpkg uses Clang.
当端口文件指定了依赖项时,vcpkg 也会下载并安装这些依赖项。When the portfile specifies dependencies, vcpkg downloads and installs them too.下载后,vcpkg 将使用库所使用的同一生成系统生成库。After downloading, vcpkg builds the library by using the same build system the library uses.CMake 和 MSBuild(Windows 上)项目是首选,但同时还支持 MAKE 以及其他任何生成系统。CMake and (on Windows) MSBuild projects are preferred, but MAKE is supported, along with any other build system.如果 vcpkg 在本地计算机上找不到指定的生成系统,它会下载并安装一个。If vcpkg can't find the specified build system on the local machine, it downloads and installs it.
对于 CMAKE 项目,通过 CMAKE_TOOLCHAIN_FILE 来配合使用库和 find_package()
。For CMAKE projects, use CMAKE_TOOLCHAIN_FILE to make libraries available with find_package()
.例如:For example:
列出已安装的库List the libraries already installed
在安装了某些库后,你可以使用 vcpkg list 来查看所获得的内容 :After you've installed some libraries, you can use vcpkg list to see what you have:
与 Visual Studio (Windows) 集成Integrate with Visual Studio (Windows)
按用户Per-user
运行 vcpkg integrate install 来配置 Visual Studio,以便按用户找到所有 vcpkg 标头文件和二进制文件 。Run vcpkg integrate install to configure Visual Studio to locate all vcpkg header files and binaries on a per-user basis.无需手动编辑 VC++ 目录路径。There's no need for manual editing of VC++ Directories paths.如果有多个克隆,那么你从中运行此命令的克隆则将成为新的默认位置。If you have multiple clones, the clone you run this command from becomes the new default location.
现在,只需键入文件夹/标头即可轻松加入 (#include) 标头,并且自动完成功能将帮助你完成这一切。Now you can #include headers simply by typing the folder/header, and autocomplete assists you.在链接到 lib 或添加项目引用时,无需额外步骤。No additional steps are required for linking to libs or adding project references.下图演示了 Visual Studio 查找 azure-storage-cpp 标头的方法。The following illustration shows how Visual Studio finds the azure-storage-cpp headers.vcpkg 将其标头放置在 /installed 子文件夹中,由目标平台予以分区 。vcpkg places its headers in the /installed subfolder, partitioned by target platform.下图显示库的 /was 子文件夹中包含文件的列表 :The following diagram shows the list of include files in the /was subfolder for the library:
按项目Per project
如果需要使用的库的版本与活动 vcpkg 实例中的版本不同,请按以下步骤操作:If you need to use a specific version of a library that's different from the version in your active vcpkg instance, follow these steps:
- 新建 vcpkg 克隆Make a new clone of vcpkg
- 修改库的端口文件以获取所需版本Modify the portfile for the library to obtain the version you need
- 运行 vcpkg install <library> 。Run vcpkg install <library>.
- 使用 vcpkg integrate project 创建 NuGet 包,它会按项目来引用该库。Use vcpkg integrate project to create a NuGet package that references that library on a per-project basis.
与 Visual Studio Code (Linux/MacOS) 集成Integrate with Visual Studio Code (Linux/MacOS)
运行 vcpkg integrate install 在 Linux/MacOS 上配置 Visual Studio Code 。Run vcpkg integrate install to configure Visual Studio Code on Linux/MacOS.此命令将设置 vcpkg 登记的位置,并对源文件启用 IntelliSense。This command sets the location of the vcpkg enlistment and enables IntelliSense on source files.
通过 WSL 从 Windows 指向 LinuxTarget Linux from Windows via WSL
可使用适用于 Linux 的 Windows 子系统(也称为 WSL)在 Windows 计算机上生成 Linux 二进制文件。You can produce Linux binaries on a Windows machine by using the Windows Subsystem for Linux, or WSL.按照说明在 Windows 10 上设置 WSL,并使用适用于 Linux 的 Visual Studio 扩展进行配置。Follow the instructions to Set up WSL on Windows 10, and configure it with the Visual Studio extension for Linux.可以将所有针对 Windows 和 Linux 生成的库放入同一文件夹中。It's okay to put all your built libraries for Windows and Linux into the same folder.可以从 Windows 和 WSL 访问它们。They're accessible from both Windows and WSL.
导出已编译的二进制文件和标头Export compiled binaries and headers
让团队中的每位成员都下载和生成公用库是一种效率较低的做法。It's inefficient to make everyone on a team download and build common libraries.可以单独让一位团队成员使用 vcpkg export 命令创建二进制文件和标头的通用 zip 文件,或者创建 NuGet 包 。A single 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.
更新/升级已安装的库Update/upgrade installed libraries
公共目录始终与最新版本的库保持一致。The public catalog is kept up to date with the latest versions of the libraries.要判断哪个本地库已过期,请使用 vcpkg update 。To determine which of your local libraries are out-of-date, use vcpkg update.准备好将端口集合更新到最新版本的公共目录后,请运行 vcpkg upgrade 命令 。When you're ready to update your ports collection to the latest version of the public catalog, run the vcpkg upgrade command.它会自动下载并重新生成已过期的任意或所有已安装的库。It automatically downloads and rebuilds any or all of your installed libraries that are out of date.
默认情况下,upgrade 命令仅列出过期库;而不会对它们进行升级。By default, the upgrade command only lists the libraries that are out of date; it doesn’t upgrade them.若要真正升级这些库,请使用 --no-dry-run 选项 。To actually upgrade the libraries, use the --no-dry-run option.
升级选项Upgrade Options
- --no-dry-run 执行升级,在没有指定条件的情况下,命令只列出过期的包。--no-dry-run Perform the upgrade; when not specified, the command only lists the out-of-date packages.
- --keep-going 继续安装包(即使出现了失败)。--keep-going Continue installing packages even if one fails.
- --triplet <t> 为非限定的包设置默认的三元组。--triplet <t> Set the default triplet for unqualified packages.
- --vcpkg-root <path> 指定要使用的 vcpkg 目录,而不是使用当前目录或工具目录。--vcpkg-root <path> Specify the vcpkg directory to use instead of current directory or tool directory.
升级示例Upgrade example
以下示例演示如何只升级指定的库。The following example shows how to upgrade only specified libraries.必要时 vcpkg 会自动拉取依赖项。vcpkg automatically pulls in dependencies as necessary.
发布新库Contribute new libraries
可以在自己的专用端口集合中添加任意库。You can include any libraries you like in your private ports collection.要建议适合公共目录的新库,请在 GitHub vcpkg 问题页上打开一个问题。To suggest a new library for the public catalog, open an issue on the GitHub vcpkg issue page.
删除库Remove a library
键入 vcpkg remove 可删除已安装的库。Type vcpkg remove to remove an installed library.如果存在任何其他依赖于它的库,则系统会提示你使用 --recurse 重新运行命令,如执行此操作,则下游的所有库都会被删除 。If any other libraries depend on it, you're asked to rerun the command with --recurse, which causes all downstream libraries to be removed.
自定义 vcpkgCustomize vcpkg
可凭自身喜好随意修改 vcpkg 的克隆。You can modify your clone of vcpkg in any way you like.你甚至可以创建多个 vcpkg 克隆,然后在每个克隆中修改端口文件。You can even create multiple vcpkg clones, then modify the portfiles in each one.这是获取特定库版本或指定特定命令行参数的一种简单方法。That's a simple way to obtain specific library versions, or to specify particular command-line parameters.例如,在企业中,各个开发人员组可能在具有一组特定于他们所在组的依赖项的软件上工作。For example, in an enterprise, individual groups of developers might work on software that has a set of dependencies specific to their group.解决方法是为每个团队设置一个 vcpkg 的克隆。The solution is to set up a clone of vcpkg for each team.然后,修改克隆以下载库版本,并设置每个团队需要的编译开关。Then, modify the clones to download the library versions and set the compilation switches that each team needs.
卸载 vcpkgUninstall vcpkg
只需删除 vcpkg 目录。Just delete the vcpkg directory.删除此目录会卸载 vcpkg 分发以及 vcpkg 已安装的所有库。Deleting this directory uninstalls the vcpkg distribution, and all the libraries that vcpkg has installed.
发送关于 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 文件夹层次结构The vcpkg folder hierarchy
所有 vcpkg 功能和数据都自包含在称为“实例”的单独目录层次结构中。All vcpkg functionality and data is self-contained in a single directory hierarchy, called an '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).
命令行参考Command-line reference
命令Command | 描述Description |
---|---|
vcpkg search [pat]vcpkg search [pat] | 搜索可安装的包Search for packages available to install |
vcpkg install <pkg>..vcpkg install <pkg>.. | 安装包Install a package |
vcpkg remove <pkg>..vcpkg remove <pkg>.. | 卸载包Uninstall a package |
vcpkg remove --outdatedvcpkg remove --outdated | 卸载所有过期包Uninstall all out-of-date packages |
vcpkg listvcpkg list | 列出已安装的包List installed packages |
vcpkg updatevcpkg update | 显示用于更新的包列表Display list of packages for updating |
vcpkg upgradevcpkg upgrade | 重新生成所有过期包Rebuild all outdated packages |
vcpkg hash <file> [alg]vcpkg hash <file> [alg] | 通过特定算法对文件执行哈希操作,默认为 SHA512Hash a file by specific algorithm, default SHA512 |
vcpkg integrate installvcpkg integrate install | 使已安装包在用户范围内可用。Make installed packages available user-wide.首次使用时需要管理权限Requires admin privileges on first use |
vcpkg integrate removevcpkg integrate remove | 删除用户范围的集成Remove user-wide integration |
vcpkg integrate projectvcpkg integrate project | 为使用单个 VS 项目生成引用 NuGet 包Generate a referencing NuGet package for individual VS project use |
vcpkg export <pkg>.. [opt]..vcpkg export <pkg>.. [opt].. | 导出包Export a package |
vcpkg edit <pkg>vcpkg edit <pkg> | 打开端口进行编辑(使用 %EDITOR%,默认为“code”)Open up a port for editing (uses %EDITOR%, default 'code') |
vcpkg create <pkg> <url> [archivename]vcpkg create <pkg> <url> [archivename] | 创建新程序包Create a new package |
vcpkg cachevcpkg cache | 列出缓存的已编译包List cached compiled packages |
vcpkg versionvcpkg version | 显示版本信息Display version information |
vcpkg contact --surveyvcpkg contact --survey | 显示联系信息,以便发送反馈。Display contact information to send feedback. |
选项Options
选项Option | 描述Description |
---|---|
--triplet <t>--triplet <t> | 指定目标体系结构三元组。Specify the target architecture triplet.(默认:%VCPKG_DEFAULT_TRIPLET% ,另请参阅“vcpkg help triplet” )(default: %VCPKG_DEFAULT_TRIPLET% , see also vcpkg help triplet) |
--vcpkg-root <path>--vcpkg-root <path> | 指定 vcpkg 根目录(默认:%VCPKG_ROOT% )Specify the vcpkg root directory (default: %VCPKG_ROOT% ) |
vcpkg는 C++ 용 명령줄 패키지 관리자입니다.vcpkg is a command-line package manager for C++.vcpkg는 Windows, Linux 및 MacOS에서 타사 라이브러리 획득 및 설치를 크게 간소화합니다.It greatly 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 카탈로그의 모든 라이브러리가 isual 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.vcpkg는 현재 Windows 및 Linux/MacOS 카탈로그 사이에서 1900개 이상의 라이브러리를 지원합니다.Between the Windows and Linux/MacOS catalogs, vcpkg now supports over 1900 libraries.C++ 커뮤니티는 지속적으로 두 카탈로그에 더 많은 라이브러리를 추가하고 있습니다.The C++ community is adding more libraries to both catalogs on an ongoing basis.
단순하면서도 유연한Simple yet flexible
하나의 명령으로 소스를 다운로드하고 라이브러리를 구축할 수 있습니다.With a single command, you can download sources and build a library.vcpkg는 그 자체가 GitHub에서 사용할 수 있는 오픈 소스 프로젝트입니다.vcpkg is itself an open-source project, available on GitHub.원하는 방식으로 프라이빗 vcpkg 클론을 사용자 지정할 수 있습니다.It's possible to customize your private vcpkg clones in any way you like.예를 들어 다른 라이브러리 또는 공용 카탈로그에서 발견되는 것과는 다른 버전의 라이브러리를 지정할 수 있습니다.For example, specify different libraries, or different versions of libraries than the ones found in the public catalog.단일 컴퓨터에 여러 개의 vcpkg 복제본을 가질 수 있습니다.You can have multiple clones of vcpkg on a single machine.각 항목은 원하는 컴파일 스위치를 사용하여 라이브러리의 사용자 지정 컬렉션을 생성하도록 설정될 수 있습니다.Each one may be set to produce a custom collection of libraries, with your preferred compilation switches.각 복제본은 자체 계층에서만 작동하는 vcpkg.exe의 자체 복사본이 포함된 자체 포함 환경입니다.Each clone 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.
이진 파일이 아닌 소스Sources, not binaries
Windows 카탈로그에 있는 라이브러리의 경우 vcpkg는 이진 파일1 대신 소스를 다운로드합니다.For libraries in the Windows catalog, vcpkg downloads sources instead of binaries1.찾을 수 있는 가장 최신 Visual Studio 버전을 사용하여 해당 소스를 컴파일합니다.It compiles those sources using the most recent version of Visual Studio that it can find.C++에서는 애플리케이션 코드와 사용하는 모든 라이브러리가 동일한 컴파일러 및 컴파일러 버전을 사용하여 컴파일되어야 합니다.In C++, it's important that both your application code and any libraries you use are compiled by the same compiler, and compiler version.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 are standardized on a specific version of a compiler, one team member can use vcpkg to download sources and compile a set of binaries.그런 다음 내보내기 명령을 사용하여 이진 파일과 헤더를 압축하여 다른 팀 구성원에게 내보낼 수 있습니다.Then they can use the export command to zip up the binaries and headers for other team members.자세한 내용은 아래의 컴파일된 이진 파일 및 헤더 내보내기를 참조하세요.For more information, see Export compiled binaries and headers below.
또한 포트 컬렉션에 프라이빗 라이브러리가 있는 vcpkg 클론을 만들 수 있습니다.You can also create a vcpkg clone that has private libraries in the ports collection.미리 작성된 이진 파일 및 헤더를 다운로드하는 포트를 추가합니다.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.
1참고: 일부 독점 라이브러리에서는 소스를 사용할 수 없습니다. 이러한 경우 vcpkg는 호환되는 미리 작성된 이진 파일을 다운로드합니다.1Note: sources are unavailable for some proprietary libraries. In these cases, vcpkg downloads compatible prebuilt binaries.
설치Installation
GitHub에서 vcpkg 리포지토리(https://github.com/Microsoft/vcpkg)를 복제합니다.Clone the vcpkg repo from GitHub: https://github.com/Microsoft/vcpkg.원하는 폴더 위치에 다운로드할 수 있습니다.You can download to any folder location you prefer.
다음과 같이 루트 폴더에서 부트스트래퍼를 실행합니다.Run the bootstrapper in the root folder:
- bootstrap-vcpkg.bat(Windows)bootstrap-vcpkg.bat (Windows)
- ./bootstrap-vcpkg.sh(Linux, MacOS)./bootstrap-vcpkg.sh (Linux, MacOS)
사용 가능한 라이브러리 목록 검색Search the list of available libraries
사용 가능한 패키지를 보려면 명령 프롬프트에서 다음을 입력합니다. vcpkg searchTo see what packages are available, at the command prompt type: vcpkg search
이 명령은 vcpkg/ports 하위 폴더에 제어 파일을 열거합니다.This command enumerates the control files in the vcpkg/ports subfolders.다음과 같은 목록이 표시됩니다.You'll see a listing like this:
패턴으로 필터링 할 수 있습니다(예: vcpkg search ta).You can filter on a pattern, for example vcpkg search ta:
로컬 컴퓨터에 라이브러리 설치Install a library on your local machine
vcpkg search를 사용하여 라이브러리 이름을 찾은 후에 vcpkg install을 사용하여 라이브러리를 다운로드하고 컴파일합니다.After you get the name of a library by using vcpkg search, you use vcpkg install to download the library and compile it.vcpkg는 포트 디렉터리에 있는 라이브러리의 포트 파일을 사용합니다.vcpkg uses the library's portfile in the ports directory.triplet을 지정하지 않으면 vcpkg는 대상 플랫폼에 대해 기본 triplet(x86-windows, x64-linux.cmake 또는 x64-osx.cmake)을 설치하고 컴파일합니다.If no triplet is specified, vcpkg will install and compile for the default triplet for the target platform: x86-windows, x64-linux.cmake, or x64-osx.cmake.
Linux 라이브러리의 경우 vcpkg는 gcc가 로컬 시스템에 설치되어 있는지 여부에 따라 다릅니다.For Linux libraries, vcpkg depends on gcc being installed on the local machine.MacOS에서는 vcpkg가 Clang을 사용합니다.On MacOS, vcpkg uses Clang.
포트 파일이 종속성을 지정할 때 vcpkg도 해당 항목을 다운로드하고 설치합니다.When the portfile specifies dependencies, vcpkg downloads and installs them too.다운로드 후 vcpkg는 라이브러리가 사용하는 빌드 시스템과 동일한 시스템을 사용하여 라이브러리를 빌드합니다.After downloading, vcpkg builds the library by using the same build system the library uses.CMake 및 MSBuild 프로젝트(Windows)가 선호되지만 MAKE도 다른 빌드 시스템과 함께 지원됩니다.CMake and (on Windows) MSBuild projects are preferred, but MAKE is supported, along with any other build system.vcpkg가 로컬 컴퓨터에서 지정된 빌드 시스템을 찾을 수 없으면 다운로드하여 설치합니다.If vcpkg can't find the specified build system on the local machine, it downloads and installs it.
CMAKE 프로젝트의 경우 CMAKE_TOOLCHAIN_FILE을 사용하여 find_package()
에서 라이브러리를 사용할 수 있도록 합니다.For CMAKE projects, use CMAKE_TOOLCHAIN_FILE to make libraries available with find_package()
.예를 들어:For example:
이미 설치된 라이브러리 나열List the libraries already installed
일부 라이브러리를 설치한 후에 vcpkg list를 사용하여 설치된 라이브러리를 확인할 수 있습니다.After you've installed some libraries, you can use vcpkg list to see what you have:
Mar 18, 2020 When the process is complete, Photos opens your library. Follow these steps to use the Photos repair tool: Make sure that you backed up your main Photos library. Quit Photos if it's open. Press and hold the Option and Command keys as you open Photos again. The Repair Library dialog appears. Mar 18, 2020 If your Photos library won't open, or if Photos behaves unexpectedly, the Photos library repair tool might resolve the issues. Follow these steps to use the Photos library repair tool: Hold down the Option and Command keys while you open Photos on your Mac. In the dialog that appears, click Repair to start the repair process. May 21, 2018 Photos app for the Mac imports images and manages pictures by automatically moving the files into organized folders within the apps dedicated package file. While this file container is not intended to be user facing, many advanced Mac OS users like to have access to the original master files rather than solely relying on the Photos app for image management. Jul 12, 2017 Maybe it’s become corrupted and Photos won’t open, or maybe you just want to start fresh and archive your old one. Regardless, to create a new System Photo Library, first open the location where your current system library is and drag it to a backup spot if you want to keep it (recommended). Mac sierra won't open picture library from file transfer. Jan 08, 2018 Should not be an issue because the format of the drive does not effect the type of file (in this case probably JPEGs), so if El Capitan was able to read the drive and copy the photos to the Mac's internal drive, that should not effect Sierra's ability to see and read them.
Visual Studio와 통합(Windows)Integrate with Visual Studio (Windows)
사용자 단위Per-user
vcpkg integrate install을 실행하여 사용자 단위로 모든 vcpkg 헤더 파일과 이진 파일을 찾도록 Visual Studio를 구성할 수 있습니다.Run vcpkg integrate install to configure Visual Studio to locate all vcpkg header files and binaries on a per-user basis.VC + + 디렉터리 경로를 수동으로 편집할 필요가 없습니다.There's no need for manual editing of VC++ Directories paths.클론이 여러 개 있는 경우 이 명령을 실행하는 클론이 새 기본 위치가 됩니다.If you have multiple clones, the clone you run this command from becomes the new default location.
이제 폴더/헤더를 입력하는 것만으로 헤더를 포함할 수 있으며 자동 완성이 도움이 됩니다.Now you can #include headers simply by typing the folder/header, and autocomplete assists you.라이브러리에 연결하거나 프로젝트 참조를 추가하는 추가 단계는 필요 없습니다.No additional steps are required for linking to libs or adding project references.다음 그림에서는 Visual Studio가 azure-storage-cpp 헤더를 찾는 방법을 보여 줍니다.The following illustration shows how Visual Studio finds the azure-storage-cpp headers.vcpkg는 대상 플랫폼으로 분할된 /installed 하위 폴더에 헤더를 배치합니다.vcpkg places its headers in the /installed subfolder, partitioned by target platform.다음 다이어그램에서는 라이브러리의 /was 하위 폴더에 있는 포함 파일의 목록을 보여줍니다.The following diagram shows the list of include files in the /was subfolder for the library:
프로젝트 단위Per project
활성 vcpkg 인스턴스에서 버전과 다른 라이브러리의 특정 버전을 사용해야 하는 경우 다음 단계를 따르세요.If you need to use a specific version of a library that's different from the version in your active vcpkg instance, follow these steps:
- vcpkg의 새 클론을 생성합니다.Make a new clone of vcpkg
- 필요한 버전을 가져오도록 라이브러리의 프로필을 수정합니다.Modify the portfile for the library to obtain the version you need
- vcpkg install <library> 를 실행합니다.Run vcpkg install <library>.
- vcpkg integrate project를 사용하여 프로젝트 단위로 해당 라이브러리를 참조하는 NuGet 패키지를 만듭니다.Use vcpkg integrate project to create a NuGet package that references that library on a per-project basis.
Visual Studio Code와 통합(Linux/MacOS)Integrate with Visual Studio Code (Linux/MacOS)
vcpkg 통합 설치를 실행하여 Linux/MacOS에서 Visual Studio Code를 구성합니다.Run vcpkg integrate install to configure Visual Studio Code on Linux/MacOS.이 명령은 vcpkg 인리스트먼트 위치를 설정하고 소스 파일에서 IntelliSense를 사용하도록 설정합니다.This command sets the location of the vcpkg enlistment and enables IntelliSense on source files.
WSL을 통해 Windows에서 Linux 대상 지정Target Linux from Windows via WSL
WSL(Linux용 Windows 하위 시스템)을 사용하여 Windows 컴퓨터에서 Linux 바이너리를 생성할 수 있습니다.You can produce Linux binaries on a Windows machine by using the Windows Subsystem for Linux, or WSL.Windows 10에 WSL을 설정 지침에 따라 Linux용 Visual Studio 확장을 사용하여 구성합니다.Follow the instructions to Set up WSL on Windows 10, and configure it with the Visual Studio extension for Linux.Windows 및 Linux용으로 빌드된 모든 라이브러리를 동일한 폴더에 배치하는 것이 좋습니다.It's okay to put all your built libraries for Windows and Linux into the same folder.Windows 및 WSL 모두에서 액세스할 수 있습니다.They're accessible from both Windows and WSL.
컴파일된 이진 파일 및 헤더 내보내기Export compiled binaries and headers
팀의 모든 사용자가 공통 라이브러리를 다운로드하고 작성하는 것은 비효율적입니다.It's inefficient to make everyone on a team download and build common libraries.단일 팀 멤버는 vcpkg export 명령을 사용하여 이진 파일 및 헤더의 일반 zip 파일 또는 NuGet 패키지를 만들 수 있습니다.A single 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.
설치된 라이브러리 업데이트/업그레이드Update/upgrade installed libraries
공용 카탈로그는 라이브러리의 최신 버전으로 최신 상태로 유지됩니다.The public catalog is kept up to date with the latest versions of the libraries.로컬 라이브러리 중 어떤 것이 오래되었는지 확인하려면 vcpkg update를 사용합니다.To determine which of your local libraries are out-of-date, use vcpkg update.포트 컬렉션을 공용 카탈로그의 최신 버전으로 업데이트할 준비가 되면 vcpkg upgrade 명령을 실행합니다.When you're ready to update your ports collection to the latest version of the public catalog, run the vcpkg upgrade command.최신 버전이 아닌 설치된 모든 라이브러리를 자동으로 다운로드하여 다시 작성합니다.It automatically downloads and rebuilds any or all of your installed libraries that are out of date.
기본적으로는 upgrade 명령은 만료된 라이브러리를 나열할 뿐 업그레이드하지는 않습니다.By default, the upgrade command only lists the libraries that are out of date; it doesn’t upgrade them.실제로 라이브러리를 업그레이드하려면 --no-dry-run 옵션을 사용합니다.To actually upgrade the libraries, use the --no-dry-run option.
업그레이드 옵션Upgrade Options
- --no-dry-run 업그레이드를 수행합니다. 지정되지 않은 경우 명령은 만료된 패키지를 나열합니다.--no-dry-run Perform the upgrade; when not specified, the command only lists the out-of-date packages.
- --keep-going 한 번 실패하더라도 패키지를 계속 설치합니다.--keep-going Continue installing packages even if one fails.
- --triplet <t> 정규화되지 않은 패키지에 대한 세 가지 기본값을 설정합니다.--triplet <t> Set the default triplet for unqualified packages.
- --vcpkg-root <path> 현재 디렉터리 또는 도구 디렉터리 대신 사용할 vcpkg 디렉터리를 지정합니다.--vcpkg-root <path> Specify the vcpkg directory to use instead of current directory or tool directory.
Brew Boost
업그레이드 예제Upgrade example
다음 예제에서는 지정된 라이브러리를 업그레이드하는 방법을 보여줍니다.The following example shows how to upgrade only specified libraries.vcpgk는 필요에 따라 자동으로 종속성을 가져옵니다.vcpkg automatically pulls in dependencies as necessary.
새 라이브러리 제공Contribute new libraries
Boost For Mac
원하는 모든 라이브러리를 개인 포트 컬렉션에 포함할 수 있습니다.You can include any libraries you like in your private ports collection.공용 카탈로그에 대한 새 라이브러리를 제안하려면 GitHub vcpkg 문제 페이지에서 문제를 엽니다.To suggest a new library for the public catalog, open an issue on the GitHub vcpkg issue page.
라이브러리 제거Remove a library
vcpkg remove를 입력하여 설치된 라이브러리를 제거합니다.Type vcpkg remove to remove an installed library.종속된 라이브러리가 있는 경우 모든 다운스트림 라이브러리가 제거되는 --recurse를 사용하여 명령을 다시 실행하라는 메시지가 표시됩니다.If any other libraries depend on it, you're asked to rerun the command with --recurse, which causes all downstream libraries to be removed.
Vcpkg 사용자 지정Customize vcpkg
원하는 어떤 방식으로든 vcpkg의 클론을 수정할 수 있습니다.You can modify your clone of vcpkg in any way you like.여러 vcpkg 클론을 만든 다음 각 클론에서 포트 파일을 수정할 수도 있습니다.You can even create multiple vcpkg clones, then modify the portfiles in each one.이 방법은 특정 라이브러리 버전을 얻거나 특정 명령줄 매개 변수를 지정하는 간단한 방법입니다.That's a simple way to obtain specific library versions, or to specify particular command-line parameters.예를 들어 기업에서 개별 개발자 그룹은 해당 그룹과 관련된 종속성 집합이 있는 소프트웨어에서 작업할 수 있습니다.For example, in an enterprise, individual groups of developers might work on software that has a set of dependencies specific to their group.해결 방법은 각 팀에 대해 vcpkg의 클론을 설정하는 것입니다.The solution is to set up a clone of vcpkg for each team.그런 다음 복제본을 수정하여 라이브러리 버전을 다운로드하고 각 팀에 필요한 컴파일 스위치를 설정합니다.Then, modify the clones to download the library versions and set the compilation switches that each team needs.
vcpkg 제거Uninstall vcpkg
vcpkg 디렉터리를 삭제하면 됩니다.Just delete the vcpkg directory.이 디렉터리를 삭제하면 vcpkg 배포 및 vcpkg에 의해 설치된 모든 라이브러리가 제거됩니다.Deleting this directory uninstalls the vcpkg distribution, and all the libraries that vcpkg has installed.
vcpkg에 대한 사용자 의견 보내기Send feedback about vcpkg
vcpkg contact --survey 명령을 사용하여 기능에 대한 버그 보고서 및 제안을 비롯하여 vcpkg에 대한 사용자 의견을 Microsoft에 보냅니다.Use the vcpkg contact --survey command to send feedback to Microsoft about vcpkg, including bug reports and suggestions for features.
Vcpkg 폴더 계층 구조The vcpkg folder hierarchy
모든 vcpkg 기능 및 데이터는 단일 디렉터리 계층 구조에서 독립적이며 '인스턴스'라고 합니다.All vcpkg functionality and data is self-contained in a single directory hierarchy, called an '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).
명령줄 참조Command-line reference
Install Boost C++ Library Machine
명령Command | 설명Description |
---|---|
vcpkg search [pat]vcpkg search [pat] | 설치할 수 있는 패키지 검색Search for packages available to install |
vcpkg install <pkg>..vcpkg install <pkg>.. | 패키지 설치Install a package |
vcpkg remove <pkg>..vcpkg remove <pkg>.. | 패키지 제거Uninstall a package |
vcpkg remove --outdatedvcpkg remove --outdated | 만료된 패키지 모두 제거Uninstall all out-of-date packages |
vcpkg listvcpkg list | 설치된 패키지 나열List installed packages |
vcpkg updatevcpkg update | 업데이트할 패키지 목록 표시Display list of packages for updating |
vcpkg upgradevcpkg upgrade | 만료된 모든 패키지 다시 빌드Rebuild all outdated packages |
vcpkg hash <file> [alg]vcpkg hash <file> [alg] | 특정 알고리즘에 따라 파일 해시, 기본 SHA512Hash a file by specific algorithm, default SHA512 |
vcpkg integrate installvcpkg integrate install | 설치된 패키지를 누구나 사용할 수 있도록 설정Make installed packages available user-wide.처음 사용할 때 관리자 권한 필요Requires admin privileges on first use |
vcpkg integrate removevcpkg integrate remove | 사용자 수준 통합 제거Remove user-wide integration |
vcpkg integrate projectvcpkg integrate project | 개별 VS 프로젝트 사용을 위한 참조 NuGet 패키지 생성Generate a referencing NuGet package for individual VS project use |
vcpkg export <pkg>.. [opt]..vcpkg export <pkg>.. [opt].. | 패키지 내보내기Export a package |
vcpkg edit <pkg>vcpkg edit <pkg> | 편집할 포트 열기(%EDITOR% 사용, 기본 '코드')Open up a port for editing (uses %EDITOR%, default 'code') |
vcpkg create <pkg> <url> [archivename]vcpkg create <pkg> <url> [archivename] | 새 패키지 만들기Create a new package |
vcpkg cachevcpkg cache | 컴파일된 캐시 패키지 나열List cached compiled packages |
vcpkg versionvcpkg version | 버전 정보 표시Display version information |
vcpkg contact --surveyvcpkg contact --survey | 사용자 의견을 보낼 연락처 정보를 표시합니다.Display contact information to send feedback. |
옵션Options
Install Boost C++ Mac
옵션Option | 설명Description |
---|---|
--triplet <t>--triplet <t> | 세 가지 대상 아키텍처를 지정합니다.Specify the target architecture triplet.(기본값: %VCPKG_DEFAULT_TRIPLET% , vcpkg help triplet 참조)(default: %VCPKG_DEFAULT_TRIPLET% , see also vcpkg help triplet) |
--vcpkg-root <path>--vcpkg-root <path> | vcpkg 루트 디렉터리 지정(기본값: %VCPKG_ROOT% )Specify the vcpkg root directory (default: %VCPKG_ROOT% ) |