c运行时动态库的几种配置方式

1、LD_LIBRARAY_PATH方式。系统管理员和DBA经常使用,oracle的做法。

2、修改配置文件/etc/ld.so.conf,然后执行ldconfig命令。

[lightdb@sdw ~]$ cat /etc/ld.so.c
ld.so.cache ld.so.conf ld.so.conf.d/
[lightdb@sdw ~]$ cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
[lightdb@sdw ~]$ cat /etc/ld.so.conf.d/
kernel-4.19.90-23.8.v2101.ky10.aarch64.conf opencryptoki-aarch64.conf sssd-aarch64.conf tracker-aarch64.conf
mysql-aarch64.conf openldap-aarch64.conf sudo-aarch64.conf tracker-miners-aarch64.conf
[lightdb@sdw ~]$ cat /etc/ld.so.conf.d/kernel-4.19.90-23.8.v2101.ky10.aarch64.conf
# Placeholder file, no vDSO hwcap entries used in this kernel.
[lightdb@sdw ~]$ cat /etc/ld.so.conf.d/mysql-aarch64.conf
/usr/lib64/mysql

3、编译的时候指定gcc参数 -Wl,-rpath。准确的说是链接参数,ld的参数。适合制作二进制版压缩包,全部自包含。例如依赖了三方源码,但是又不希望或无法安装到系统默认目录/usr/local/lib时可以使用。

 

posted @ 2021-10-08 13:14  zhjh256  阅读(137)  评论(0编辑  收藏  举报