xcode dyld 未加载原因:找不到图像 libopencv_core.2.4.dylib
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13554520/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
dyld not loaded Reason: image not found libopencv_core.2.4.dylib
提问by kava
I'm still quite new to Objective C and Xcode, but I just finished a small app that uses the openCV libopencv_core.2.4.2.dylib
.
我对 Objective C 和 Xcode 还是很陌生,但我刚刚完成了一个使用 openCV 的小应用程序libopencv_core.2.4.2.dylib
。
When I went to open the final built app on another machine, OS X threw me this error:
当我在另一台机器上打开最终构建的应用程序时,OS X 向我抛出了这个错误:
Dyld Error Message: Library not loaded: */libopencv_core.2.4.dylib
Referenced from: /Users/USER/Desktop/my
app.app/Contents/MacOS/my app
Reason: image not found
Why is my app looking for 2.4 instead of 2.4.2 here?
为什么我的应用在这里寻找 2.4 而不是 2.4.2?
What I already checked:
我已经检查过的:
I added a new build phase -> so that libopencv_core.2.4.2.dylib
is copied to the app package (via "Copy Bundle Resources" in Xcode) - libopencv_core.2.4.2.dylib
now lies in my app.app/Resources
我添加了一个新的构建阶段 -> 以便将libopencv_core.2.4.2.dylib
其复制到应用程序包(通过 Xcode 中的“复制捆绑资源”) -libopencv_core.2.4.2.dylib
现在位于我的app.app/Resources
What did I miss? Do I have so set some more library search paths or similar?
我错过了什么?我是否设置了更多库搜索路径或类似路径?
What I also did:
我还做了什么:
install_name_tool -id "@executable_path/../Frameworks/libopencv_core.2.4.2.dylib" libopencv_core.2.4.2.dylib
Copying the dylib to the Frameworks directory doesn't work either:
将 dylib 复制到 Frameworks 目录也不起作用:
Library not loaded: @executable_path/../Frameworks/libopencv_core.2.4.2.dylib
Don't know what to do now - the dylib isin the Frameworks directory of my app...
不知道现在该做什么-在dylib是在我的应用程序的框架目录...
Using otool -L
on the binary gives me:
otool -L
在二进制文件上使用给了我:
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 19.0.0)
@loader_path/../Frameworks/libopencv_core.2.4.2.dylib (compatibility version 2.4.0, current version 2.4.2)
@loader_path/../Frameworks/libopencv_highgui.2.4.2.dylib (compatibility version 2.4.0, current version 2.4.2)
@loader_path/../Frameworks/libopencv_imgproc.2.4.2.dylib (compatibility version 2.4.0, current version 2.4.2)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 945.11.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 744.1.0)
/System/Library/Frameworks/CoreData.framework/Versions/A/CoreData (compatibility version 1.0.0, current version 407.7.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1187.33.0)
采纳答案by kava
I found a better solution: recompiling openCV in Xcode and set the @executable_path/../Frameworks
in the build settings, for every .dylib you compile - now the .dylibs
themselves always "know where they are".
我找到了一个更好的解决方案:在 Xcode 中重新编译 openCV 并@executable_path/../Frameworks
在构建设置中设置,对于您编译的每个 .dylib - 现在.dylibs
它们自己总是“知道它们在哪里”。
回答by kunalg
I had the same problem. i keep all .dylib in system root directory usr/libit working fine. At the run time .o file not get .dylib file path then it gives an error.
我有同样的问题。我将所有 .dylib 保存在系统根目录usr/lib 中,它工作正常。在运行时 .o 文件没有得到 .dylib 文件路径然后它给出一个错误。
回答by Halil Kaskavalci
Since other answers are not clear enough;
由于其他答案不够清楚;
Assume your dylib files are located in /usr/local/opt/opencv3/lib
假设您的 dylib 文件位于 /usr/local/opt/opencv3/lib
sudo ln -s /usr/local/opt/opencv3/lib/*.dylib /usr/local/lib
will solve this problem. Be aware that /usr/lib
is protected by system in MacOS, thus you should use /usr/local/lib
.
将解决这个问题。请注意,/usr/lib
在 MacOS 中受系统保护,因此您应该使用/usr/local/lib
.