我对 Objective C 和 Xcode 还是很陌生,但我刚刚完成了一个使用 openCV 的小应用程序libopencv_core.2.4.2.dylib
。
当我在另一台机器上打开最终构建的应用程序时,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
为什么我的应用在这里寻找 2.4 而不是 2.4.2?
我已经检查过的内容:
我添加了一个新的构建阶段 -> 以便将libopencv_core.2.4.2.dylib
其复制到应用程序包中(通过 Xcode 中的“复制捆绑资源”) -libopencv_core.2.4.2.dylib
现在位于我的app.app/Resources
我错过了什么?我是否设置了更多的库搜索路径或类似路径?
我还做了什么:
install_name_tool -id "@executable_path/../Frameworks/libopencv_core.2.4.2.dylib" libopencv_core.2.4.2.dylib
将 dylib 复制到 Frameworks 目录也不起作用:
Library not loaded: @executable_path/../Frameworks/libopencv_core.2.4.2.dylib
不知道现在该做什么 - dylib在我的应用程序的 Frameworks 目录中......
在二进制文件上使用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)