问题
My application was running fine using homebrew-installed OpenCV. In trying to make the application distributable, I compiled and installed OpenCV using plain Cmake. This didn't work, I deleted the files created by Cmake, and reverted to my last "working" commit. However, now my app won't run anymore and it complains of not finding required dylibs:
dyld: Library not loaded: /usr/local/opt/opencv/lib/libopencv_core.2.4.5.dylib
I have no reference to "/usr/local/opt" in my Xcode project at all, confirmed by a full-text search of the directory. Where is it getting this?
However, I have a perfectly good Homebrew install of OpenCV 2.4.5. As far as I know, there are three places to tell Xcode where to look for libraries:
- Under "Build Phases", "Link Binary With Libraries"
- Under "Build Settings", "Library Search Paths" (Set to /usr/local/Cellar/opencv/2.4.5/lib)
- Unser "Build Settings", "Header Search Paths" (Set to /usr/local/Cellar/opencv/2.4.5/include)
All of these are set to the correct homebrew install paths.
回答1:
Figured it out. First of all, I hadn't uninstalled the cmake version correctly: I didn't know you could do a make uninstall
. Not sure if this was needed, but good to do it right.
Second, I hadn't noticed Homebrew had thrown some errors when installing OpenCV. In particular, it hadn't been able to link OpenCV due to the conflicting files. I deleted all the files it mentioned in "Possible conflicting files are:".
Then I ran brew link opencv
and boom everything is running again!
来源:https://stackoverflow.com/questions/20382164/xcode-cant-find-dylibs-after-switching-to-homebrew-for-opencv