尝试运行我在Mac OS X中发送的可执行文件时,出现以下错误
dyld: Library not loaded: libboost_atomic.dylib
Referenced from: /Users/"Directory my executable is in"
Reason: image not found
Trace/BPT trap:5
Run Code Online (Sandbox Code Playgroud)
我已经安装了boost库,它们位于/opt/local/lib.我认为这个问题与可执行文件有关,只查看它所在的目录,就像我在那里粘贴'libboost_atomic.dylib'一样,它不再关心它了.不幸的是,它抱怨它无法找到下一个升级库.
有没有一种简单的方法来解决这个问题?
我正在使用最新版本的Xcode 4开发Cocoa应用程序,我想将动态库链接到我的项目(dylibs).
我读的地方,在我的项目库添加是不够的,因为我有运行install_name_tool,并otool让我的项目中使用我的项目被捆绑的库.
我已经阅读了手册页install_name_tool,但我不明白为什么我必须这样做.
图书馆如何运作?特别感兴趣的是应用程序和库具有指向我机器中特定位置的路径的部分,例如/usr/local/lib/mylibrary.dylib运行时otool -L
我正在尝试在构建之后更改dylib的安装路径.我otool -L用来检查当前路径是什么.然后我做:
$ install_name_tool -change /my/current/path/libmine.dylib \
/my/new/path/libmine.dylib libmine.dylib
Run Code Online (Sandbox Code Playgroud)
我没有收到错误,但没有任何变化.如果我再次检查路径,旧路径仍在那里.此外,新路径比旧路径要短得多,所以没有问题,我认为lib甚至可以使用额外的标志进行编译,以获得更多的文件路径空间.
有任何想法吗?
我有一个程序依赖于它希望在目录结构内部找到的共享库.我想将该共享库移到更好的位置.在OS X上,可以使用install_name_tool完成此操作.我无法找到Linux的等价物.
作为参考,readelf -d myprogram吐出以下释义输出:
Dynamic section at offset 0x1e9ed4 contains 30 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [this/is/terrible/library.so]
0x00000001 (NEEDED) Shared library: [libGL.so.1]
0x00000001 (NEEDED) Shared library: [libGLU.so.1]
0x00000001 (NEEDED) Shared library: [libstdc++.so.6]
(continues in an uninteresting fashion)
Run Code Online (Sandbox Code Playgroud)
(并根据要求,ldd myprogram:)
linux-gate.so.1 => (0x0056a000)
this/is/terrible/library.so => not found
libGL.so.1 => /usr/lib/mesa/libGL.so.1 (0x0017d000)
libGLU.so.1 => /usr/lib/libGLU.so.1 (0x00a9c000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00710000)
(etc, etc)
Run Code Online (Sandbox Code Playgroud)
我想将"this/is/terrible/library.so"改为"shared/library.so".请注意,如果程序保留在其"构建"位置,其中/// ter//.实际存在的相对路径,则ldd能够找到它,正如您所期望的那样.
我知道RPATH并不是我想要的,我不需要在全球范围内改变搜索路径.
我正在开发一个插件包,说MyPlugIn.bundle 一个应用程序,说BigApp.app.比如说,这个捆绑包需要一个dylibMyPlugIn.bundle/Contents/Resources/library.dylib.我已经重新定位了library.dylib的路径,就像我为一个简单的应用程序包所做的那样:
$ otool -L MyPlugIn.bundle/Contents/MacOS/MyPlugIn
MyPlugIn.bundle/Contents/MacOS/MyPlugIn:
@executable_path/../Resources/library.dylib (compatibility version 0.0.0, current version 0.0.0)
[...]
$ otool -L MyPlugIn.bundle/Contents/Resources/library.dylib
MyPlugIn.bundle/Contents/Resources/library.dylib:
@executable_path/../Resources/library.dylib (compatibility version 0.0.0, current version 0.0.0)
[...]
Run Code Online (Sandbox Code Playgroud)
但是BigApp.app无法加载此捆绑包,Mac OS X的Console.app会记录以下内容:
19/01/10 15:42:59 BigApp[51516] Error loading /Library/Application Support/BigApp/Plug-Ins/MyPlugIn.bundle/Contents/MacOS/MyPlugIn: dlopen(/Library/Application Support/BigApp/Plug-Ins/MyPlugIn.bundle/Contents/MacOS/MyPlugIn, 262): Library not loaded: @executable_path/../Resources/library.dylib
Referenced from: /Library/Application Support/BigApp/Plug-Ins/MyPlugIn.bundle/Contents/MacOS/MyPlugIn
Reason: image not found
Run Code Online (Sandbox Code Playgroud)
似乎@executable_path不是由MyPlugIn.bundle可执行路径替换,而是由BigApp.app可执行路径替换.
任何解决方法,没有绝对路径,以便它可以在Mac OS X 10.4(Tiger)上运行?谢谢.
相关,但不回答这个问题:
在OSX上,我有一个由打包管理器提供的动态库,安装在非标准目录中,install_name只是文件名.例如:
$ ROOT=$PWD
$ mkdir $ROOT/foo
$ cd $ROOT/foo
$ echo 'int foo(int a, int b){return a+b;}' > foo.c
$ clang foo.c -dynamiclib -install_name libfoo.dylib -o libfoo.dylib
Run Code Online (Sandbox Code Playgroud)
我不想改变(绝对路径,@ RPATH,...)libfoo.dylib的install_name使用install_name_tool -id.
现在我将程序与库链接,例如:
$ mkdir $ROOT/bar
$ cd $ROOT/bar
$ echo 'int foo(int,int); int main(){return foo(2,4);}' > main.c
$ clang main.c -L../foo -lfoo
Run Code Online (Sandbox Code Playgroud)
该程序无法运行:
$ ./a.out
dyld: Library not loaded: libfoo.dylib
Referenced from: $ROOT/bar/./a.out
Reason: image not found
Trace/BPT trap: 5
Run Code Online (Sandbox Code Playgroud)
因为:
$ otool -L ./a.out …Run Code Online (Sandbox Code Playgroud) 我已经在这个概念上挣扎了一段时间,我无法真正理解-change和之间的区别-id。手册页指出
-id name
Changes the shared library identification name of a dynamic shared library to name. If the Mach-O binary is not a dynamic
shared library and the -id option is specified it is ignored.
-change old new
Changes the dependent shared library install name old to new in the specified Mach-O binary. More than one of these options
can be specified. If the Mach-O binary does not contain the old install name in a specified …Run Code Online (Sandbox Code Playgroud) 我正在开发一个使用GStreamer库的应用程序.为了便于部署,我想收集本地捆绑中的所有GStreamer库.为此我写了一个小脚本,执行以下操作:
otool -L)install_name_tool)(如果您有兴趣,可以查看Ruby脚本.)
但是,我现在看到gst_init呼叫上的运行时错误:
(process:22843): GLib-GObject-CRITICAL **: gtype.c:2458: initialization assertion failed, use g_type_init() prior to this function
(process:22843): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed
Run Code Online (Sandbox Code Playgroud)
只有在我使用本地化库时才会出现这些错误.
Are there certain 'common pitfalls' when it comes to using install_name_tool? Does anyone have an idea what I could be doing wrong? If you need to know certain details then feel free to ask.
Update
I changed a few things:
每次我尝试在我的机器上使用install_name_tool时,它会报告以下内容
install_name_tool: object: Abacate malformed object (unknown load command 4)
Run Code Online (Sandbox Code Playgroud)
我读到构建二进制文件时可能会出错.为了检查我创建最简单的hello world c ++程序并尝试使用install_name_tool更改某些内容.没工作.我究竟做错了什么?
目前我有运行Snow Leopard OS的XCode 4.2.
我需要重新链接一个文件install_name_tool.有问题的文件允许我更改其中一个dylib路径,但是当我更改第二个(7个)时,我收到此错误:
install_name_tool: changing install names or rpaths can't be redone for: some/library (for architecture i386) because larger updated load commands do not fit (the program must be relinked, and you may need to use -headerpad or -headerpad_max_install_names)
Run Code Online (Sandbox Code Playgroud)
在谷歌搜索后,我发现文件中的新路径没有足够的空间,我可能能够使用该ld工具,或者libtool解决这个问题.但是,我无法弄清楚如何.我没有这个库的源代码,所以我无法重新编译它.
有没有办法让我更新这个文件的所有dylib路径?任何帮助将非常感谢!
我在osx 10.10我正在使用的命令: install_name_tool -change old/dylib/path.dylib new/dylib/path.dylib file/to/update