本人在Mac系统上尝试下载opencv源码,然后通过cmake,make,make install命令编译安装,都失败,各种依赖缺失报错。最后通过brew install --build-from-source opencv安装成功。
这里面虽然通过brew install成功了,但是背后还是cmake,make,make install,为什么这么说,因为在执行brew install之前,做了很多准备工作。
0、这里使用的是brew install,它安装的时候,直接把各种缺少的依赖给装上了,而opencv的安装,需要大量的三方依赖,这些依赖都是需要源码安装的,所以需要设置brew安装源,就像我们在linux下使用yum,apt安装一样,这里设置一下国内源,会提升安装效率。
#进入homebrew安装目录下的Library/Taps,依次通过git命令设置homebrew,homebrew-core,homebrew-cask项目源
cd $(brew --repo)/Library/Taps
cd homebrew
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew.git
cd homebrew-core
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
cd ../homebrew-cask
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
这三个项目地址,默认都是github的地址。更换为https://mirrors.ustc.edu.cn中科大的源之后,安装各种依赖会非常快。
1、安装xcode命令行工具,不是非要安装xcode开发工具,xcode de