visual studio怎么添加vcpkg 库
时间: 2023-10-22 13:07:20 浏览: 214
添加 vcpkg 库的步骤如下:
1. 下载 vcpkg:可以在 vcpkg 的 GitHub 页面(https://github.com/microsoft/vcpkg)下载最新版本的 vcpkg。
2. 安装 vcpkg:将下载好的 vcpkg.exe 文件放到你想要安装 vcpkg 的文件夹中,然后在该文件夹中打开命令行窗口,运行以下命令:
```
.\vcpkg.exe bootstrap-vcpkg
```
这个命令会下载和安装 vcpkg 的依赖项,并为其生成用于构建和安装 C++ 库的工具链。
3. 安装需要的库:在命令行窗口中输入以下命令,安装需要的库,例如安装 OpenCV 库:
```
.\vcpkg.exe install opencv
```
这个命令会下载和编译 OpenCV 库,并将其安装到 vcpkg 安装目录的“installed”文件夹中。
4. 在 Visual Studio 中使用 vcpkg 库:在 Visual Studio 中创建新的 C++ 项目,在项目属性中设置 vcpkg 库的路径和要使用的库。
具体步骤如下:
- 在 Visual Studio 中打开项目,右键单击项目,选择“属性”。
- 在属性窗口中,选择“VC++ 目录”。
- 在“包含目录”中添加 vcpkg 的 include 目录,例如:D:\vcpkg\installed\x86-windows\include。
- 在“库目录”中添加 vcpkg 的 lib 目录,例如:D:\vcpkg\installed\x86-windows\lib。
- 在“链接器” -> “输入”中添加要使用的库的名称,例如:opencv_world451.lib。
这样设置之后,就可以在 Visual Studio 中使用 vcpkg 安装的库。
阅读全文
相关推荐

















