- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
GNU 编译器集合(又名 gcc)和 ld 提供了多种指定库搜索路径的方法,其中包括 -rpath
和 -L
标志。联机帮助页显示这两个标志之间没有差异,实际上是说每个标志都将一个库添加到库搜索路径中。然而,这两个标志的作用完全相同似乎很奇怪。这两个选项之间有什么区别(如果有)?
最佳答案
您一定正在阅读一些过时的联机帮助页副本(已添加重点):
-rpath=dir
Add a directory to the runtime library search path. This is used
when linking an ELF executable with shared objects. All -rpath
arguments are concatenated and passed to the runtime linker, which
uses them to locate shared objects at runtime.
对比
-L searchdir
--library-path=searchdir
Add path searchdir to the list of paths that ld will search for
archive libraries and ld control scripts.
因此,-L
告诉 ld
在链接时在哪里查找要链接的库。例如,当您针对构建树中的库进行构建时,可以使用此选项,这些库将通过 make install
放入正常的系统库路径中。另一方面,--rpath
将该路径存储在可执行文件中,以便运行时动态链接器可以找到库。当您的库位于系统库搜索路径之外时,可以使用此选项。
关于gcc - -rpath 和 -L 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8482152/
如果共享库链接到二进制文件,并且共享库还依赖于其他库,那么共享库的 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
我是一名优秀的程序员,十分优秀!