dyld:未加载库:../lib/abc.dynlib [英] dyld: Library not loaded: ../lib/abc.dynlib

查看:103
本文介绍了dyld:未加载库:../lib/abc.dynlib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法让我的XCode 4.2项目针对动态库(dynlib)运行.

I am having trouble getting a my XCode 4.2 project to run against a dynamic library (dynlib).

我正在做的是将库添加到xcode项目中,然后使用此lib创建一个新的复制文件"构建阶段.

What I am doing is adding the library into xcode project, and then creating a new 'Copy Files' build phase with this lib.

如果我在构建阶段将Destination设置为"Products Directory",则该项目的运行会很好(!),但随后我必须随同该应用程序一起交付该lib,而不是将其嵌入其中.

The project does(!) run well if I set the Destination in the build phase to 'Products Directory', but then I have to deliver the lib with the app as opposed to embedded inside it.

在构建阶段,我在Destination的所有其他设置中出现标题错误.

I get the error in the title in all other settings of Destination in the build phase.

此外,我尝试退出xcode,删除构建目录,清理以及所有此类技巧.

Also, I tried to quit xcode, delete build directory, clean, and all such tricks.

我是否缺少项目/目标设置? 为什么XCode在'../lib/'中寻找dynlib? (如错误所示)

Is there a project/target setting I am missing? Why is XCode looking for the dynlib in '../lib/'? (as shown in error)

推荐答案

您有两个选择a)更改库ID,b)更改最终产品.

You have two options a) change the library ID, b) change the final product.

该ID嵌入在dylib中,它定义了dyld在哪里寻找它.该ID是在链接时(不使用其他特殊标志时)从库中获取的.您可以使用otool -L进行检查,例如:

The ID is embedded in the dylib and it defines where dyld will look for it. The ID is taken from the library at link time (when no other special flags are used). You can check it with otool -L, e.g.:

gammu:~$ otool -L /usr/lib/libz.dylib 
/usr/lib/libz.dylib:
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.0.0)

第一行是dylib的ID.您可以使用install_name_tool -id <path> <library>进行更改.一种选择是使用特殊形式的@executable_path/...,它看起来从二进制文件的位置开始(还有其他位置).

The first line is the ID of the dylib. You can change it using install_name_tool -id <path> <library>. One option you have is to use the special form @executable_path/... which looks starting from the location of your binary (there are others as well).

第二个选项(实现相同的目的)是更改产品中库的路径.您可以使用相同的otool -L命令检查它如何链接库:

The second option (achieving the same thing) is to change the path to the library in your product. You can check how it links libraries with the same otool -L command:

gammu:~$ otool -L /usr/bin/emacs
/usr/bin/emacs:
    /usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.0.0)

然后您可以使用install_name_tool -change <old> <new> <target>更改库,例如:

You can then change the libraries with install_name_tool -change <old> <new> <target>, e.g.:

install_name_tool -change ../lib/abc.dynlib @executable_path/../lib/abc.dylib foo

最后,请注意,如果让Xcode管理dylib(而不是手动复制),通常Xcode会自动为您完成所有操作.

Finally, note that Xcode usually does all this for you automatically if you let it manage the dylib (instead of copying it manually).

这篇关于dyld:未加载库:../lib/abc.dynlib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆