5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MacでOpenCVがインストールされているのにcmake出来ない問題

Posted at

はじめに

エラーへの対処なのですが,エラー文に出力されたコマンドを実行しただけなので,役に立たないかもしれませんが,書いておきます.

cmakeのエラー内容

cmake実行時のエラー部抜粋が以下.

error
CMake Error at CMakeLists.txt:8 (find_package):
  By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "OpenCV", but
  CMake did not find one.

  Could not find a package configuration file provided by "OpenCV" with any
  of the following names:

    OpenCVConfig.cmake
    opencv-config.cmake

  Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
  "OpenCV_DIR" to a directory containing one of the above files.  If "OpenCV"
  provides a separate development package or SDK, be sure it has been
  installed.

とりあえず$ brew install opencvとすると良いでしょう(OpenCVのバージョンを気にする方は気をつけてください).

すでにインストールされている場合は,

error
pass/to/build $ brew install opencv

Warning: opencv 4.1.0_2 is already installed, it's just not linked
You can use `brew link opencv` to link this version.

と出力されます.言われた通りに$ brew link opencvと実行します.

error
pass/to/build $ brew link opencv

Linking /usr/local/Cellar/opencv/4.1.0_2...
Error: Could not symlink lib/python3.7/site-packages/cv2/__init__.py
Target /usr/local/lib/python3.7/site-packages/cv2/__init__.py
already exists. You may want to remove it:
  rm '/usr/local/lib/python3.7/site-packages/cv2/__init__.py'

To force the link and overwrite all conflicting files:
  brew link --overwrite opencv

To list all files that would be deleted:
  brew link --overwrite --dry-run opencv

失敗しました.言われるがままに,

succes
pass/to/build $ brew link --overwrite opencv

Linking /usr/local/Cellar/opencv/4.1.0_2... 227 symlinks created

以上で,cmakeができるようになりました.

おわりに

エラーで言われた通りにしたので微妙な情報ですが,誰かの役に立てばと思います.

5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?