RPath is a very interesting topic which can instruct the binary to find the right location of libraries and dependencies.
GNU ld.so has some rules in regarding how to use the rpath to find the right dependencies (basically it has attribute or environment which direct the runtime to look for directories for things within).
You may find some explaination from this wikipedia link: http://en.wikipedia.org/wiki/Rpath
GNU ld.so
The dynamic linker of the GNU C Library and its derivative Embedded GLIBC implement a rather complicated algorithm for searching for shared libraries. The basic search order is:[1]
- The (colon-separated) paths in the
DT_RPATH
dynamic section attribute of the binary if present andDT_RUNPATH
attribute does not exist. - The (colon-separated) paths in the environment variable
LD_LIBRARY_PATH
, unless the executable is asetuid/setgid
binary, in which case it is ignored.LD_LIBRARY_PATH
can be overridden by calling the dynamic linker with the option--library-path
(e.g./lib/ld-linux.so.2 --library-path $HOME/mylibs myprogram
). - The (colon-separated) paths in the
DT_RUNPATH
dynamic section attribute of the binary if present. - Lookup based on the
ldconfig
cache file (often located at/etc/ld.so.cache
) which contains a compiled list of candidate libraries previously found in the augmented library path (set by/etc/ld.so.conf
). If, however, the binary was linked with the-z nodeflib
linker option, libraries in the default library paths are skipped. - In the trusted default path
/lib
, and then/usr/lib
. If the binary was linked with the-z nodeflib
linker option, this step is skipped.
Notes:
- The option
--inhibit-rpath LIST
of the dynamic linker instructs it to ignoreDT_RPATH
andDT_RUNPATH
attributes of the object names in LIST. - Libraries specified by the environment variable
LD_PRELOAD
and then those listed in/etc/ld.so.preload
are loaded before the search begins. A preload can thus be used to replace some (or all) of the requested library's normal functionalities, or it can simply be used to supply a library that would otherwise not be found. - Static libraries are searched and linked into the ELF file at link time and are not linked at run time.
[edit]The role of GNU ld
The GNU Linker (GNU ld) implements a feature which it calls "new-dtags": [2]
If the new-dtags feature is enabled in the linker (at run time using --enable-new-dtags
), GNU ld
, besides setting the DT_RPATH
attribute, also sets the DT_RUNPATH
attribute to the same string. At run time, if the dynamic linker finds a DT_RUNPATH
attribute, it ignores the value of the DT_RPATH
attribute, with the effect that LD_LIBRARY_PATH
is checked next and the paths in theDT_RUNPATH
attribute are only searched after it.
This means that in such configurations, the paths in LD_LIBRARY_PATH
are searched before those given at link time using -rpath
if--enable-new-dtags
was active.
Instead of specifying the -rpath
to the linker, the environment variable LD_RUN_PATH
can be set to the same effect.
相关推荐
3. **LD_LIBRARY_PATH环境变量**:这是在运行时设置的,可以通过改变这个环境变量来临时修改库的搜索路径。 4. **RUNPATH二进制头**:同样是在构建时设置的,但与RPATH不同,它适用于可执行文件。 5. **基本库目录**...
在命令行界面中,这可以通过`-D`选项完成,例如`-DOPENCV_FFMPEG_DIR=path/to/ffmpeg`和`-DIPPICV_PATH=path/to/ippicv`。 4. **重新生成项目**:完成配置后,运行`generate`命令生成项目文件,然后使用生成的项目...
/usr/bin/ld: warning: libpgtypes.so.1, needed by /usr/lib/libecpg.so, not found (try using -rpath or -rpath-link) /usr/bin/ld: warning: libpq.so.3, needed by /usr/lib/libecpg.so, not found (try using ...
PatchELF是用于修改现有ELF可执行文件和库的简单实用程序。 特别是,它可以执行以下操作: ... 例如,如果可执行文件引用一个库libfoo.so ,并且具有RPATH /lib:/usr/lib:/foo/lib ,而libfoo.so只能在/
首先,我们来安装Nginx。Nginx是一款轻量级的Web服务器,以其高并发性能和稳定性而受到广泛欢迎。...4. 配置编译选项,包括指定安装路径、启用PHP-FPM、CLI以及各种扩展:`./configure --prefix=/usr/local/...
第三步:编译php ./configure --enable-fpm --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable- mbregex --enable-mbstring --enable-ftp --...
rPath公司的核心产品之一是rPath Linux,它不仅提供了一个具有高度可定制性的操作系统基础架构,而且在本质上是一个集成解决方案,让ISV能够通过rPath的rBuilder工具轻松创建符合自身需求的操作系统镜像。...
[root@linuxsir01 mysql-4.0.16]# ./configure --prefix=/opt/mysql --with-mysqld-user=beinan --with-charset=gb2312 --with-extra-charsets=all --with-unix-socket-path=/opt/mysql/var/mysql.sock ``` 其中...
-with-libxml-dir --enable-xml --disable-debug --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-...
在Linux系统中搭建一个基于MySQL、PHP和Nginx的环境是常见的Web开发配置,这种组合通常被称为LAMP(Linux, Apache, MySQL, PHP)架构,但在本例中使用的是Nginx代替Apache,所以是... ./configure --prefix=/usr/local/...
... ...在Linux环境下,我们需要先解压这个文件,使用以下命令: ...在编译前,确保系统已经安装了必要的依赖库,如`libxml2`,`openssl`,`curl`,`zlib`等。可以使用`apt-get`或`yum`..../configure --prefix=/usr/local/...
... 一、环境准备 在开始安装前,确保你的CentOS系统是最新的,可以使用以下命令进行更新: ...sudo yum update -y ...sudo yum install -y libxml2 libxml2-devel openssl openssl-devel..../configure --prefix=/usr/local/...
-with-config-file-path=/usr/local/php/etc --with-mysql-sock=/var/run/mysql/mysql.sock --with-mcrypt=/usr /i nclude --with-mhash --with-openssl --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd ...
在构建一个基于Linux系统的Web开发环境时,常常需要手动编译安装Apache、MySQL和PHP,这一过程对于初学者来说可能有些复杂。... 首先,让我们从MySQL开始。MySQL是一款开源的关系型..../configure --prefix=/usr/local/...
-with-config-file-path=/usr/local/php/etc --with-mysql-sock=/var/run/mysql/mysql.sock --with-mcrypt=/usr /i nclude --with-mhash --with-openssl --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd ...
-with-config-file-path=/usr/local/php/etc --with-mysql-sock=/var/run/mysql/mysql.sock --with-mcrypt=/usr /i nclude --with-mhash --with-openssl --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd ...
-with-config-file-path=/usr/local/php/etc --with-mysql-sock=/var/run/mysql/mysql.sock --with-mcrypt=/usr/include --with-mhash --with-openssl --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --...
在本教程中,我们将详细介绍如何在CentOS 6.0最小化安装环境下,手动编译安装Nginx、MySQL、PHP以及Zend Optimizer。...4. 配置编译选项,包括Nginx、MySQL、FastCGI支持等:`./configure --prefix=/usr/local/...
--extra-ldflags="-Wl,-rpath-link,/path/to/ndk/platforms/android-21/arch-arm/usr/lib -L/path/to/ndk/platforms/android-21/arch-arm/usr/lib -nostdlib" \ --enable-cross-compile \ --disable-shared \ --...