LoginSignup
1
0

More than 3 years have passed since last update.

[メモ] macOSでOpenCVのビルドがエラーになる件

Last updated at Posted at 2020-11-20

背景

普段はbrew install opencv や、 pip install opencv-python して使えば良いのだが、設定変更してビルドする必要が生じたので、公式に従ってビルドしてみたら、エラーとなったのでメモ。

  • macOS Catalina 10.15.7
  • Clang 12.0.0
  • OpenCV 4.2.0 のSourceCode

opencvフォルダのあるところで、

bash
mkdir build_opencv
cd build_opencv
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=ON ../opencv
make

解決策

結果として以下のように、 BUILD_JPEG_TURBO_DISABLE = ON を追加すれば良い。

cmake -DCMAKE_BUILD_TYPE = Release  -DBUILD_JPEG_TURBO_DISABLE=ON -DBUILD_EXAMPLES = ON ../opencv

原因

3rdparty/libjpeg-turbo のCMakeFile.txtにset(JPEG_LIB_VERSION 62)と定義されているが、#if JPEG_LIB_VERSION >= 70の時しか_jpeg_default_qtablesが定義されない様子。

参考

問題のログ

bash
$ make
[  2%] Built target zlib
[  5%] Built target libjpeg-turbo
[  7%] Built target libtiff
[ 15%] Built target libwebp
[ 18%] Built target libjasper
[ 19%] Built target libpng
[ 26%] Built target IlmImf
[ 28%] Built target ippiw
[ 34%] Built target libprotobuf
[ 34%] Built target quirc
[ 34%] Built target ittnotify
[ 35%] Built target ade
[ 35%] Built target opencv_videoio_plugins
[ 42%] Built target opencv_core
[ 47%] Built target opencv_imgproc
[ 47%] Built target opencv_imgproc
[ 47%] Linking CXX shared library ../../lib/libopencv_imgcodecs.dylib
Undefined symbols for architecture x86_64:
  "_jpeg_default_qtables", referenced from:
      cv::JpegEncoder::write(cv::Mat const&, std::__1::vector<int, std::__1::allocator<int> > const&) in grfmt_jpeg.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libopencv_imgcodecs.4.2.0.dylib] Error 1
make[1]: *** [modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/all] Error 2
make: *** [all] Error 2
1
0
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
1
0