构建依赖于共享库的程序后,如何更改共享库的文件名? [英] How can I change the filename of a shared library after building a program that depends on it?

查看:118
本文介绍了构建依赖于共享库的程序后,如何更改共享库的文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个依赖于共享库的程序,希望可以在目录结构的深处找到它.我想将共享库移到一个更好的位置.在OS X上,可以使用install_name_tool来完成.我找不到适用于Linux的同类产品.

I have a program that depends on a shared library it expects to find deep inside a directory structure. I'd like to move that shared library out and into a better place. On OS X, this can be done with install_name_tool. I'm unable to find an equivalent for Linux.

作为参考,readelf -d myprogram吐出以下释义的输出:

For reference, readelf -d myprogram spits out the following paraphrased output:

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)

(并应要求提供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)

,我想将"this/is/terrible/library.so"更改为"shared/library.so".请注意,如果程序留在其已构建"位置,即this/is/terrible/library.so的相对路径实际存在的位置,那么ldd可以按照您的期望找到它.

and I would like to errata "this/is/terrible/library.so" to be "shared/library.so". Note that, if the program is left in its "built" location, where the relative path this/is/terrible/library.so actually exists, then ldd is able to find it, as you'd expect.

我了解RPATH,这不是我想要的,我不需要全局更改搜索路径.

I know about RPATH and it isn't what I'm looking for, I don't need to change search paths globally.

推荐答案

HT -这可能会有所帮助.

HT - this might be helpful.

HT是可执行文件的文件编辑器/查看器/分析器.目标是将调试器的低级功能与IDE的可用性相结合.我们计划实现所有(十六进制)编辑功能并支持最重要的文件格式.

HT is a file editor/viewer/analyzer for executables. The goal is to combine the low-level functionality of a debugger and the usability of IDEs. We plan to implement all (hex-)editing features and support of the most important file formats.

我找不到与ZorbaTHut解决方案有很大不同的东西,但是也许可以输入一个长度不同的名称,并且仍然保持二进制有效.

I couldn't find something much different from ZorbaTHut's solution, but perhaps it's possible to put a name with different length and still keep the binary valid.

gelf -这也可能很有用.

gelf - this could be useful too.

GElf是用于操作的通用,独立于ELF类的API, ELF目标文件. GElf提供了一个单一的,通用的 用于处理32位和64位ELF格式目标文件的表面.

GElf is a generic, ELF class-independent API for manipulat- ing ELF object files. GElf provides a single, common inter- face for handling 32-bit and 64-bit ELF format object files.

这篇关于构建依赖于共享库的程序后,如何更改共享库的文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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