关于使用vcpkg的一些技巧补充

一、个性化编译

vcpkg install opencv[cuda]:x64-windows 

这样就会安装好具有Cuda加速的opencv 库。

但是由于VS2017 CUDA8.0 CUDA9.0 CUDA9.1 版本的兼容问题

但是如果在我们使用CMake编译成功的话,这种定制化编译也一定会成功

参考博客:

https://blog.csdn.net/ewqapple/article/details/78428062

二、错误分析方法

使用vcpkg时,会碰到CMake错误。 有些以前能编译通过的包, 过一段时间又不能编译错误了,错误提示一般是CMake错误。

处理错误的步骤:

  1. 分析错误
  2. 查看错误日志
  3. 查看cmake文件
  4. 手工处理错误

下面是我opencv编译错误解决过程:

1.  执行vcpkg命令

./vcpkg.exe install opencv

2.  错误信息

Starting package 15/23: opencv:x64-windows
Building package opencv[core,eigen,flann,jpeg,opengl,png,tiff]:x64-windows...
-- Downloading https://github.com/opencv/opencv/archive/3.4.3.tar.gz...
-- Downloading https://github.com/opencv/opencv/archive/3.4.3.tar.gz... Failed. Status: 18;"Transferred a partial file"
CMake Error at scripts/cmake/vcpkg_download_distfile.cmake:156 (message):

      Failed to download file.
      If you use a proxy, please set the HTTPS_PROXY and HTTP_PROXY environment
      variables to "https://user:password@your-proxy-ip-address:port/".
      Otherwise, please submit an issue at https://github.com/Microsoft/vcpkg/issues

Call Stack (most recent call first):
  scripts/cmake/vcpkg_from_github.cmake:108 (vcpkg_download_distfile)
  ports/opencv/portfile.cmake:5 (vcpkg_from_github)
  scripts/ports.cmake:71 (include)


Error: Building package opencv:x64-windows failed with: BUILD_FAILED
Please ensure you're using the latest portfiles with `.\vcpkg update`, then
submit an issue at https://github.com/Microsoft/vcpkg/issues including:
  Package: opencv:x64-windows
  Vcpkg version: 2018.11.23-nohash

Additionally, attach any relevant sections from the log files above.

 3. 查看错误日志(XXX-err.log)

参考博客:

http://www.bubuko.com/infodetail-2238260.html

三、默认x86 或者 x64

vcpkg默认安装32位的包,为了让它安装64位的包,可以添加系统环境变量:

VCPKG_DEFAULT_TRIPLET=x64-windows


最后确认下我自己的版本,因为这个更新特别快,不一定下次就好使:

猜你喜欢

转载自blog.csdn.net/baidu_40840693/article/details/84719640
今日推荐