我正在尝试在我的OSX项目中使用dylib。
我已经阅读了一些示例,特别是这个: Xcode 4添加dylib 但我仍然无法让它工作。
以下是我执行的步骤:
dyld: Library not loaded: /user/local/lib/testing1.dylib Referenced from: /Users/me/testing.app/MacOS/./testing Reason: image not found
我错过了什么?
注:运行install_name_tool时,我需要使用sudo,否则会出现以下错误:
install_name_tool: can't open input file: testing.1.dylib for writing (Permission denied) install_name_tool: can't lseek to offset: 0 in file: testing.1.dylib for writing (Bad file descriptor) install_name_tool: can't write new headers in file: testing.1.dylib (Bad file descriptor) install_name_tool: can't close written on input file: testing.1.dylib (Bad file descriptor)
我已经阅读了一些示例,特别是这个: Xcode 4添加dylib 但我仍然无法让它工作。
以下是我执行的步骤:
- 将 testing.1.dylib 复制到我的 Xcode 项目文件夹中。
- 运行
sudo install_name_tool -id @executable_path/../Frameworks/testing.1.dylib testing.1.dylib
运行:
otool -L testing.1.dylib
,并收到以下内容:testing.1.dylib:
@executable_path/../Frameworks/testing.1.dylib(兼容版本2.0.0,当前版本2.0.0)
/usr/lib/libSystem.B.dylib(兼容版本1.0.0,当前版本159.1.0)将
testing.1.dylib
添加为项目的框架。(使用链接包含库选项)。- 此时,当我编译 testing1.dylib 时,它没有像我预期的那样被复制到 .App/Framework 中,因此我手动创建了 Framework 路径,并将 testing.1.dylib 复制到其中: a) mkdir -p testing.app/Contents/Frameworks b) cp testing.1.dylib testing.app/Contents/Frameworks
- 在 Xcode 中,我更新了目标和项目的
Runtime Search Paths
,分别为:@executable_path/../Frameworks。
dyld: Library not loaded: /user/local/lib/testing1.dylib Referenced from: /Users/me/testing.app/MacOS/./testing Reason: image not found
我错过了什么?
注:运行install_name_tool时,我需要使用sudo,否则会出现以下错误:
install_name_tool: can't open input file: testing.1.dylib for writing (Permission denied) install_name_tool: can't lseek to offset: 0 in file: testing.1.dylib for writing (Bad file descriptor) install_name_tool: can't write new headers in file: testing.1.dylib (Bad file descriptor) install_name_tool: can't close written on input file: testing.1.dylib (Bad file descriptor)