build applying opencv both on ubuntu and windows

pkg-config opencv --modversion is not OK
pkg-config opencv4 --modversion is OK

可以看到在执行 find_package(OpenCV 3 REQUIRED) 命令后,CMake 找到了我们安装的位于 /usr/local 下的 OpenCV 库,并设置了 CMake 变量 OpenCV_DIR 为 OpenCV 库的配置文件所在路径,正是通过载入这个路径下的 OpenCVConfig.cmake 配置文件才能配置好 OpenCV 库,然后在 OpenCVConfig.cmake 配置文件中定义了变量 OpenCV_INCLUDE_DIRS 为 OpenCV 库头文件包含路径,这样我们才能才在代码中使用

  1. down load source code
  2. cmake && make
  3. if applying “sudo make install”, then the “OpenCVConfig.cmake” under /usr/local/ will be replaced by the contemporary one
    and the version certainly will depends on that file.

if it is found anoiy, then just using set(OpenCV_DIR “path to opencv source /build”) could be used the same function as find_package(OpenCV xx REQUIRED).

The alternative method could also applied on windows while the first method(find_package) could not. It is because “make install” performs differently on ubuntu/windows, one can replace or put certain version under /usr/local while another just create one direct under build and still relied on the set() command.

as you can see in opencv build, there is OpenCVconfig.cmake, and in cmake.install.cmake there is:

set(CMAKE_INSTALL_PREFIX "/usr/local")

indicating that the folder of libs in ubuntu system.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值