可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I'm trying to install openCV 2.4.2 (not the newest version but stable version compatible with newer OS X according to several sources) on Mac OS X 10.9 (Mavericks). I have tried installing from source and using homebrew but neither works. I get the following error when I try installing it:
build Marieke$ make [ 25%] Building CXX object modules/ts/CMakeFiles/opencv_ts.dir/src/precomp.cpp.o In file included from /users/Marieke/Downloads/OpenCV-2.4.2/modules/ts/src/precomp.cpp:1: In file included from /users/Marieke/Downloads/OpenCV-2.4.2/modules/ts/src/precomp.hpp:2: In file included from /users/Marieke/Downloads/OpenCV-2.4.2/modules/ts/include/opencv2/ts/ts.hpp:40: /users/Marieke/Downloads/OpenCV-2.4.2/modules/ts/include/opencv2/ts/ts_gtest.h:1657:13: fatal error: 'tr1/tuple' file not found # include // NOLINT ^ 1 error generated. make[2]: *** [modules/ts/CMakeFiles/opencv_ts.dir/src/precomp.cpp.o] Error 1 make[1]: *** [modules/ts/CMakeFiles/opencv_ts.dir/all] Error 2 make: *** [all] Error 2
I don't know how to solve this and I have tried several things already (I do now have newest versions of Xcode, cmake, ffmpeg, faac, faad, qt, ...) so if anybody can help me, that would be much appreciated, thanks!
回答1:
Use macports. Once you install macports, just run
sudo port install opencv
at the command prompt.
This other stackoverflow question is mostly correct for how to start using the macports version of opencv in Xcode.
Here are some more up-to-date instructions for using the macports version of OpenCV from Xcode 5:
- Create a new Xcode project as OS X Application -> Command Line Tool, etc.
- Click the target in the upper left
- Click the Build Settings tab
- Scroll down to (or search for) the Search Paths section
- Under User Header Search Paths add /opt/local/include
- Click the Build Phases tab
- Click Link Binary with Libraries
- Choose the required libraries from /opt/local/lib
- At least, add libopencv_core.dylib
- Click the Run tab on the left
- Click the Arguments tab
- Enter arguments into Arguments Passed on Launch
Done! 回答2:
Run the following commands assuming you have brew installed.
brew tap homebrew/science brew install opencv
回答3:
You can try to install opencv from homebrew, I met the same problem with cmake in my 10.9 and finally I found the solution from Chris Muktar. Here are the steps:
- Make sure
xcode-select --install
Xcode command line tools 5.0.1 are installed. - Install python using brew -
brew install python
. pip update
pip install numpy
brew linkapps
- Add
export PYTHONPATH=/usr/local/Cellar/opencv/2.4.6.1/lib/python2.7/site-packages:$PYTHONPATH
to .bash_profile
in your home directory brew install opencv
In the last step I came across the Error: No available formula for opencv
. In this case, you should first run the command brew tap homebrew/science
.
Good Luck
回答4:
Thanks for the answers! I ended up with the following solution: I added #define GTEST_USE_OWN_TR1_TUPLE 1 to ts_gtest.h. Probably not the prettiest solution but I don't need gtest for anything else so it works for me.
回答5:
You could disable ts module in CMakeCache.txt file:
//Include opencv_ts module into the OpenCV build BUILD_opencv_ts:BOOL=OFF
I mean that there is no reason to modify existing code.
回答6:
I think you really need to do a configuration and that is it.
I tried your problems and I think steps are as follow:
- open terminal in mac
- in the terminal, check you have cmake and ccmake. If not, please type "brew install cmake"
- go to your downloaded opencv folder, make a new folder by typing "mkdir build", then "cd build"
- in this build folder, check you have gcc and g++ installed.
- now, doing configuration by type "ccmake .. -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++", type "c" first for configuration then exit by "e" then "g" for generating!
- you should be in terminal again now! then please type "make"
- type "sudo make install", and now the opencv is installed, check it by type "brew list", and you should see the opencv there
- type "brew linkapps"
- do a test if you have python, by typing "import cv", and it should be working!
回答7:
This may be related to the current issues with Qt on Mavericks.
See: https://github.com/mxcl/homebrew/pull/23793
I'd try installing the current patched homebrew keg for qt, and then installing opencv:
brew update brew uninstall opencv brew uninstall qt brew install -v https://raw.github.com/cliffrowley/homebrew/patched_qt/Library/Formula/qt.rb --HEAD brew install opencv
Caution to the wind: the qt build took me about an hour to complete