升级到 macOS Catalina 后使用 cmake 为 c++ 构建 opencv4 失败
Posted
技术标签:
【中文标题】升级到 macOS Catalina 后使用 cmake 为 c++ 构建 opencv4 失败【英文标题】:Build of opencv4 for c++ using cmake failing after upgrading to macOS Catalina 【发布时间】:2020-10-27 00:16:17 【问题描述】:嗨,我正在尝试使用 cmake 从源代码构建 opencv4(遵循 https://thecodinginterface.com/blog/opencv-cpp-vscode/)。我将我的 macOS 更新到 10.15 并安装了最新的 xcode。我 git 克隆了存储库并如下创建了一个构建目录,然后我尝试配置 cmake:
$ mkdir opencv
$ cd opencv
$ git clone https://github.com/opencv/opencv.git
$ cd opencv
$ git checkout tags/4.2.0
$ cd ..
$ git clone https://github.com/opencv/
$ cd opencv_contrib
$ git checkout tags/4.2.0
$ cd ..
$ cd build_opencv
$ cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=../install \
-D INSTALL_C_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ../opencv
我收到以下错误,它似乎正在尝试找到这个不存在的路径:
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework"
我已将我的 mac 版本更新到 10.15,但它似乎正在寻找 MacOSX10.14 下的路径。我在网上查过,但似乎找不到任何建议?
CMake Error in /usr/local/include/opencv/build_opencv/CMakeFiles/CMakeTmp/CMakeLists.txt:
Imported target "VTK::RenderingOpenGL2" includes non-existent path
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework"
in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
* The path was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and references files it does not
provide.
CMake Error in /usr/local/include/opencv/build_opencv/CMakeFiles/CMakeTmp/CMakeLists.txt:
Imported target "VTK::RenderingOpenGL2" includes non-existent path
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework"
in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
* The path was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and references files it does not
provide.
CMake Error in /usr/local/include/opencv/build_opencv/CMakeFiles/CMakeTmp/CMakeLists.txt:
Imported target "VTK::RenderingOpenGL2" includes non-existent path
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework"
in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
* The path was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and references files it does not
provide.
CMake Error at cmake/OpenCVDetectVTK.cmake:73 (try_compile):
Failed to generate test project build system.
Call Stack (most recent call first):
CMakeLists.txt:767 (include)
-- Configuring incomplete, errors occurred!
【问题讨论】:
安装 XCode 和安装 XCode CLT 是两个不同的任务。你两个都做了吗?您在升级到 Catalina 之前是否已经构建了这个?如果是这样,您需要摆脱旧的安装文件夹并从头开始。你检查过 openCV 的要求和它支持的内容吗? 我在升级到 Catalina 后安装了 Xcode 和 XCode CLT。我还检查了要求并安装了必要的先决条件。我只是不知道为什么它还在寻找macOS10.14下的路径?你的意思是把opencv的安装文件夹去掉,重新开始? 【参考方案1】:下载安装
XCode 12 的命令行工具
来自apple developer tools downloads。
过去,您可以执行xcode-select --install
,它会为您执行此操作,但是,现在发生了一个错误,它说它找不到包或类似的东西。因此,必须采取这种方法。
【讨论】:
以上是关于升级到 macOS Catalina 后使用 cmake 为 c++ 构建 opencv4 失败的主要内容,如果未能解决你的问题,请参考以下文章
升级到macOS Catalina 10.15.x以后 Axure无法使用
升级到 Catalina (MAC OS) 后无法访问 github