[Mac OS 10.13.3, updated Homebrew, multiple OpenCV installations]
I'm in need of a opencv.framework for a Swift/OpenCV project I'm working on in Xcode.
I found some instructions on how this may be done at Installation in iOS, and, after cloning opencv, was pleased to find the platforms/osx
folder.
Using the commend python platforms/osx/build_framework.py macos
, I was optimistic that I would get something along the lines of what I needed. However, the build failed and thus I'm here asking this question.
There are two parts to my question; how to build the desired framework version and how to fix the build errors I encountered:
(1) Since platforms/osx/build_framework.py
wasn't introduced until late 2015 (I think), I'm wondering how I might be able to build a framework around OpenCV 2.4.13.2? (platforms/osx
did not exist when I checked out the 2.4.13.2 tag.)
(1a) If (1) can't be done, I also have OpenCV versions 3.3.1_1 and 3.4.0_1 installed via Homebrew in the Cellar. (In addition, I have the 2.4.9 LinkedKeg version as well.) I'm not at liberty to simply use the latest version of OpenCV.
(2) I've included the build output of the python command below. From its output, I'm not sure why ffmpeg
was not found because I have it installed (v3.4 and v3.4.1) via Homebrew and, I have pkg-config (0.29.2) installed in /usr/local/bin, (I actually have three versions; v0.29.1, v0.29.1_1, and v0.29.2 installed via Homebrew). This may not be a critical error, as it didn't stop the build process, so I'm content to not worry about it too much at this point.
(3) However, the /usr/local/lib/cmake/vtk-6.1/VTKTargets.cmake
error is what I'm most concerned about. As with my other Homebrew packages, I have multiple versions of VTK installed; two in the Homebrew Cellar (v8.1.0 and v8.0.1_1) as well as the desired version (6.1) in LinkedKegs. All of these were automatically installed by Homebrew as dependencies of OpenCV, and I was left wondering why the latest version of OpenCV was dependent on an older version of VTK. Initially I thought I could simply create symlinks in /usr/local/lib
into the 6.1 version but soon realised there are almost 400 files. Clearly something is not right and I'm wondering if anyone here knows what needs to be done to fix this?
user@host:[ 3:59]$ python opencv/platforms/osx/build_framework.py macos
Executing: ['cmake', '-GXcode', '-DAPPLE_FRAMEWORK=ON', '-DCMAKE_INSTALL_PREFIX=install', '-DCMAKE_BUILD_TYPE=Release', '/Users/user/src/packages/OpenCV/opencv'] in /Users/user/src/packages/OpenCV/macos/build/build-x86_64-macosx
-- Can't find ffmpeg - 'pkg-config' utility is missing
-- found Intel IPP (ICV version): 2017.0.3 [2017.0.3]
-- at: /Users/user/src/packages/OpenCV/macos/build/build-x86_64-macosx/3rdparty/ippicv/ippicv_mac
-- found Intel IPP IW sources: 2017.0.3
-- at: /Users/user/src/packages/OpenCV/macos/build/build-x86_64-macosx/3rdparty/ippicv/ippiw_mac
-- LAPACK(LAPACK/Apple): LAPACK_LIBRARIES: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Accelerate.framework;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Accelerate.framework
-- LAPACK(LAPACK/Apple): Support is enabled.
CMake Error at /usr/local/lib/cmake/vtk-6.1/VTKTargets.cmake:2068 (message):
The imported target "vtkCommonMath" references the file
"/usr/local/lib/libvtkCommonMath-6.1.1.dylib"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/local/lib/cmake/vtk-6.1/VTKTargets.cmake"
but not all the files it references.
Call Stack (most recent call first):
/usr/local/lib/cmake/vtk-6.1/VTKConfig.cmake:49 (include)
cmake/OpenCVDetectVTK.cmake:2 (find_package)
CMakeLists.txt:675 (include)
-- Configuring incomplete, errors occurred!
See also "/Users/user/src/packages/OpenCV/macos/build/build-x86_64-macosx/CMakeFiles/CMakeOutput.log".
See also "/Users/user/src/packages/OpenCV/macos/build/build-x86_64-macosx/CMakeFiles/CMakeError.log".
============================================================
ERROR: Command '['cmake', '-GXcode', '-DAPPLE_FRAMEWORK=ON', '-DCMAKE_INSTALL_PREFIX=install', '-DCMAKE_BUILD_TYPE=Release', '/Users/user/src/packages/OpenCV/opencv']' returned non-zero exit status 1
============================================================
Traceback (most recent call last):
File "/Users/user/src/packages/OpenCV/opencv/platforms/ios/build_framework.py", line 112, in build
self._build(outdir)
File "/Users/user/src/packages/OpenCV/opencv/platforms/ios/build_framework.py", line 104, in _build
self.buildOne(t[0], t[1], mainBD, cmake_flags)
File "/Users/user/src/packages/OpenCV/opencv/platforms/ios/build_framework.py", line 186, in buildOne
execute(cmakecmd, cwd = builddir)
File "/Users/user/src/packages/OpenCV/opencv/platforms/ios/build_framework.py", line 36, in execute
retcode = check_call(cmd, cwd = cwd)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '['cmake', '-GXcode', '-DAPPLE_FRAMEWORK=ON', '-DCMAKE_INSTALL_PREFIX=install', '-DCMAKE_BUILD_TYPE=Release', '/Users/user/src/packages/OpenCV/opencv']' returned non-zero exit status 1