- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在 Linux 系统上使用 rpath
设置和符号链接(symbolic link)时遇到了这个问题。为了解释这个问题,我考虑了以下设置:
我有一个名为 foo
的应用程序,它依赖于 libbar.so
。该应用程序驻留在 $ROOT/pkgs/foo-1.0/bin/
中,并链接到 $ROOT/bin/
。库 libbar.so
位于 $ROOT/lib/
中。这给出了以下结构:
$ROOT/
bin/
foo --> $ROOT/pkgs/foo-1.0/bin/foo
lib/
libbar.so
pkgs/
foo-1.0/
bin/
foo
应用程序 foo
现在(以防止 LD_LIBRARY_PATH 设置)将 rpath
设置为 $ORIGIN/lib
。
现在的问题是 $ORIGIN/lib
是根据已解析的符号链接(symbolic link)解决的,而不是根据调用应用程序的路径($ROOT/bin
). 如何改变?
一个可能的解决方案是切换到硬链接(hard link),这在这种情况下有效,但我不能确保链接不会指向跨文件系统边界,也不能确保文件系统支持硬链接(hard link)。
最佳答案
The problem now is
$ORIGIN/lib
is resolved with respect to the resolved symlink and not with respect to the path from where the application is called ($ROOT/bin
). How can this be changed?
由于可执行文件不知道应用程序所在的符号链接(symbolic link)的路径,其中动态链接加载器 ld.so
解析运行时搜索路径,您的具体问题的答案是:不可能。
除此之外,nos 在他的评论中提到了可行的解决方案:您需要将 rpath 设置为 $ORIGIN/../../../lib …,或者制作 $ROOT/bin/foo
一个设置 LD_LIBRARY_PATH
的 shell 脚本。
关于linux - 通过符号链接(symbolic link)启动应用程序时如何解析 rpath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34332571/
如果共享库链接到二进制文件,并且共享库还依赖于其他库,那么共享库的 RPATH 和二进制文件的 RPATH 的优先级(链接器搜索顺序)是什么?二进制文件的 RPATH 能否覆盖共享库中的 RPATH?
我已经对我的 IOS 应用程序进行了质量扫描分析。我收到以下警告: The binary has Runpath Search Path (@rpath) set. In certain cases
我在尝试通过 QtCreator 运行之前运行的程序时收到此警告。我还收到此警告: libicui18n.so.48,/home/maxim/install/Qt/lib/libQt5Core.so
我在我的 ELF 文件上运行了arm-linux-gnueabihf-ldd(一个来自 Cygwin,别问,一个来自 Ubuntu),尽管通过包含 -rpath-link 消除了 Ubuntu 上的警
我正在构建一个 C++ 应用程序,使用 Netbeans 6.9 作为我的 IDE。我有一个 C++ 库,它是一个纯 C 库的包装器。 我已将文件正确添加到项目中(使用添加库文件选项)。这是 g++
我正在使用 cmake 创建包 我有以下结构 bin/ bin1 lib/ lib1 lib2 其中 lib1 和 lib2 是外部动态库。如何设置 RPATH 使其自动与 l
我正在为 ARM 平台进行交叉编译。在我链接的许多库文件中,只有极少数有 rpath。 我不知道它来自哪里,因为我将我需要的所有库复制到一个文件夹中,然后使用 Netbeans(在带有 Linaro
我有一个应用程序,叫它 Animal.app .在其内部 Contents/Frameworks文件夹是一个框架,比如 Mammal.framework .而在 Versions/A/Framewor
我正在使用 CMake 进行交叉编译。 在我的 CMakeLists.txt 中(用于编译和交叉编译): set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) fin
在 Linux 上使用 CMake 构建之后(但在安装之前),所有链接的库都被添加到最终可执行文件的 RPATH 中。 但是,我想添加 $ORIGIN/../lib:到这个 RPATH。 到目前为止,
我在 OS X 上构建了一个可执行文件(名为 demux),但它总是无法加载而且我找不到原因: $ ./demux RPATH failed to expanding @rpath/sfeMo
我正在尝试设置一个项目,我的存储库将所有依赖项作为 git 子模块导入,以便于开发。我的同事可以简单地克隆 repo、git submodule update --init --recursive、c
我无法使 rpath 正常工作并使我的二进制文件在指定文件夹中搜索库: 我有 3 个非常简单的文件: main.c #include #include int main() { tes
可执行文件的 rpath 指定一个或多个目录,在其中查找运行时的共享对象。 我的问题是 - 共享对象文件自身是否也有静态编译的rpath? 我最近在链接共享对象时收到运行时错误: ./example:
我必须随应用程序一起发布第三方库。因为我不想手动设置 LD_LIBRARY_PATH 或需要任何包装脚本,所以我希望 automake 设置自定义 rpath。不幸的是 libtool 有它自己的 -
我很难确定我对使用我所使用的特定工具链进行交叉编译时rpath-link是如何工作的理解(尽管我认为这是一个普遍适用于交叉编译的普遍问题)。 当我查看构建库和应用程序时将哪些标志传递给编译器和链接器时
我有一个二进制“CeeloPartyServer”,它需要在运行时在 FreeBSD 机器上找到 libFoundation.so。它们都在同一个目录中。我编译(在另一个平台上,使用交叉编译器)Cee
构建二进制文件或库时,指定rpath,即 -Wl,rpath, 告诉链接器在二进制文件运行时在哪里找到所需的库。 这里关于绝对路径和相对路径的 UNIX 哲学是什么?使用绝对路径是否更好,以便可以从任
我想在Mac OSX下设置编译时可执行文件(用于链接器)的运行时路径,以便动态链接器在程序启动时找到非标准位置的共享库。 在Linux下,可以使用-Xlinker -rpath -Xlinker /p
基本上我想在自定义字典中使用库: 编译器参数: gcc -o conftest -Wl,-rpath=/MYPATH/ssl/lib -O2 -Wno-system-headers -I/MYPAT
我是一名优秀的程序员,十分优秀!