切换到 OpenCV 的自制软件后,Xcode 找不到 dylib [英] Xcode can't find dylibs after switching to homebrew for OpenCV
问题描述
我的应用程序使用自制软件安装的 OpenCV 运行良好.在尝试使应用程序可分发时,我使用普通的 Cmake 编译并安装了 OpenCV.这不起作用,我删除了 Cmake 创建的文件,并恢复到我最后一次工作"提交.但是,现在我的应用程序将不再运行,并且抱怨找不到所需的 dylib:
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
我在我的 Xcode 项目中根本没有提到/usr/local/opt",通过目录的全文搜索证实了这一点.这是从哪里得到的?
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?
但是,我有一个非常好的 OpenCV 2.4.5 的 Homebrew 安装.据我所知,有三个地方可以告诉 Xcode 去哪里寻找库:
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:
- 在构建阶段"下,将二进制文件与库链接"
- 在Build Settings"下,Library Search Paths"(设置为/usr/local/Cellar/opencv/2.4.5/lib)
- 取消构建设置"、标题搜索路径"(设置为/usr/local/Cellar/opencv/2.4.5/include)
所有这些都设置为正确的自制软件安装路径.
All of these are set to the correct homebrew install paths.
推荐答案
想通了.首先,我没有正确卸载 cmake 版本:我不知道您可以执行 make uninstall
.不确定是否需要这样做,但做得对就好.
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.
其次,我没有注意到 Homebrew 在安装 OpenCV 时抛出了一些错误.特别是,由于文件冲突,它无法链接 OpenCV.我删除了它在可能的冲突文件是:"中提到的所有文件.
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:".
然后我运行 brew link opencv
和 boom 一切又开始运行了!
Then I ran brew link opencv
and boom everything is running again!
这篇关于切换到 OpenCV 的自制软件后,Xcode 找不到 dylib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!