移植第三方库Porting third-party libraries

将项目升级到当前版本的 Visual C++ 后,还必须升级项目使用的所有库,以便使用相同的编译器版本和风格构建库和项目。When you upgrade a project to the current version of Visual C++, you also have to upgrade any libraries that the project uses, so that the library and your project are built with the same version and flavor of the compiler. 有关详细信息,请参阅潜在的升级问题概述(For more information, see Overview of potential upgrade issues).

vcpkg 简介Introducing vcpkg

在过去,查找和升级第三方库有时并非易事。In the past, finding and upgrading 3rd party libraries was sometimes a non-trivial task. 为了更容易获取和重建 C++ 第三方开源库,Visual C++ 团队创建了一个名为 VC++ 包工具vcpkg 的命令行工具。To make it easier to acquire and rebuild C++ 3rd party open source libraries, the Visual C++ team has created a command-line tool called the VC++ Packaging Tool or vcpkg. Vcpkg 有一个可搜索目录,包含许多热门 C++ 开源库。Vcpkg has a searchable catalog of many popular C++ open-source libraries. 你可以直接从 vcpkg 命令行安装目录中的任何库。You can install any library in the catalog directly from the vcpkg command line. 安装库时,Vcpkg 会在计算机上创建一个目录树,并在此文件夹中添加 .h、.lib 和二进制文件。When you install a library, Vcpkg creates a directory tree on your machine and adds the .h, the .lib and binaries in this folder. 你可以在编译命令行中使用此文件夹,或者使用 vcpkg 集成安装命令将其集成到 Visual Studio 2015 或更高版本。You can use this folder in your compilation command line, or integrate it into Visual Studio 2015 or later by using the vcpkg integrate install command. 集成库位置后,Visual Studio 可以找到该位置,并将其添加到你创建的任何新项目中。After you integrate a library location, Visual Studio can find it and add it to any new project that you create. 若要使用库,只需要 #include 它,Visual Studio 会自动将.lib 路径添加到项目设置,并将该 dll 复制到解决方案文件夹。To use a library, just #include it, and Visual Studio will automatically add the .lib path to your project settings and copy the dll to your solution folder. 有关详细信息,请参阅 vcpkg:用于 C++ 的程序包管理器 For more information, see vcpkg: A package manager for C++.

报告问题Reporting issues

如果你的库不在 vcpkg 目录中,可以在 GitHub 存储库提出问题,社区和 Visual C++ 团队可以看到该问题,并可能会创建适用于该库的端口文件。If your library is not present in vcpkg catalog, you can open an issue on the GitHub repo where the community and the Visual C++ team can see it and potentially create the port file for this library.

对于专有的第三方库(非开源),我们建议与该库的提供商联系。For proprietary 3rd party libraries (non-open source) we recommend that you contact the library provider. 但是,我们想了解你正在使用的所有专有库,以便为你分组,请告知我们你依赖哪个库(可以通过 vcupgrade@microsoft.com 与我们联系)。However, we are interested to know of any proprietary libs you are using and block you, let us know which one you depend on (you can contact us at vcupgrade@microsoft.com).

请参阅See Also

Visual C++ 移植和升级指南Visual C++ Porting and Upgrading Guide