nm、ar、ldd、ldconfig和ld.so(Linux下的库操作工具) (2006-12-24 21:58:53)

本文介绍了 Linux 下 nm、ar、ldd 和 ldconfig 等实用工具的基本用法,包括如何查看符号表、操作静态库、检查动态链接依赖及配置动态链接器等,帮助读者更好地理解和管理 Linux 环境下的程序链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  分类: linux&qt
1、nm [options] file       列出file中的所有符号
       [option]
         -c     将符号转化为用户级的名字
         -s      当用于.a文件即静态库时,输出把符号名映射到定义该符号的模块或成员名的索引
         -u     显示在file外定义的符号或没有定义的符号
         -l     显示每个符号的行号,或为定义符号的重定义项
 
2、ar {dmpqrtx} [member] archive file       用于操作高度结构化的存档文件(.a)
       [options]
       -c       创建存档文件
       -s       创建或升级从符号到定义他们的成员之间的交叉索引映射表
       -r       替换archive中的同名文件或添加新文件
       -q       不检查而直接添加文件到存档文件的末尾
ranlib [-v|-V] file 的作用跟ar -s file相同
 
3、ldd [options] file       列出file运行所需的共享库
       [options]
       -d       执行重定位并报告所有丢失的函数
       -r       执行对函数和对象的重定位并报告丢失的任何函数或对象
 
4、 ldconfig [options] [libs]       决定位于目录/usr/lib和/lib下的共享库所需的运行的链接,这些链接由[libs]指定并被保存到/etc/ld.so.conf中
       [options]
       -p       打印文件/etc/ld.so.conf的内容
       -v       更新/etc/ld.so.conf
 
5、  ld.so       动态链接/加载器
       ld.so使用的两个环境变量
       $LD_LIBRARY_PATH 告诉ld.so去哪里查找保存在非标准目录下的共享库,冒号分隔,对应文件/etc/ld.so.conf
       $LD_PRELOAD告诉ld.so用户指定的在所有库加载之前加载的库所在的目录,空格分隔,对应文件/etc/ld.so.preload
debian12安装root@debian:/usr/src/asterisk-13.38.3# ./configure --with-crypto --with-ssl --with-srtp --with-pjproject-bundled checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking minix/config.h usability... no checking minix/config.h presence... no checking for minix/config.h... no checking whether it is safe to define __EXTENSIONS__... yes checking whether char is unsigned... no checking for uname... /usr/bin/uname checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking how to run the C preprocessor... gcc -E checking how to run the C++ preprocessor... g++ -E checking for a sed that does not truncate output... /usr/bin/sed checking for egrep... grep -E checking for ld used by gcc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for gawk... no checking for mawk... mawk checking for a BSD-compatible install... /usr/bin/install -c checking whether ln -s works... yes checking for ranlib... ranlib checking for GNU make... make checking for egrep... (cached) /usr/bin/grep -E checking for strip... strip checking for ar... ar checking for bison... : checking for cmp... /usr/bin/cmp checking for cat... /usr/bin/cat checking for cut... /usr/bin/cut checking for flex... : checking for grep... (cached) /usr/bin/grep checking for python2.7... no checking for python2... no checking for python... no checking for python3... /usr/bin/python3 checking for find... /usr/bin/find checking for basename... /usr/bin/basename checking for dirname... /usr/bin/dirname checking for sh... /bin/bash checking for ln... /usr/bin/ln checking for doxygen... : checking for dot... : checking for wget... /usr/bin/wget checking for curl... /usr/bin/curl checking for xmllint... : checking for xmlstarlet... no checking for xml... no checking for bash... /bin/bash checking for git... /usr/bin/git checking for alembic... : checking for bzip2... /usr/bin/bzip2 checking for tar... /usr/bin/tar checking for patch... /usr/bin/patch checking for sed... (cached) /usr/bin/sed checking for nm... /usr/bin/nm checking for ldconfig... /sbin/ldconfig checking for sha1sum... /usr/bin/sha1sum checking for openssl... /usr/bin/openssl checking for bison that supports parse-param... checking for soxmix... no checking for md5... no checking for md5sum... md5sum checking for a sed that does not truncate output... (cached) /usr/bin/sed checking whether gcc is Clang... no checking whether pthreads work with -pthread... yes checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE checking whether more special flags are required for pthreads... no checking for PTHREAD_PRIO_INHERIT... yes checking for RAII support... checking for gcc -fnested-functions... no checking for clang strsep/strcmp optimization... no checking for embedded pjproject (may have to download)... configuring [pjproject] Verifying /tmp/pjproject-2.10.tar.bz2 [pjproject] Verify successful [pjproject] Unpacking /tmp/pjproject-2.10.tar.bz2 [pjproject] Applying patches /usr/src/asterisk-13.38.3/third-party/pjproject/patches /usr/src/asterisk-13.38.3/third-party/pjproject/source The text leading up to this was: -------------------------- |From e8000cc80e5f8ba02cc52852edc02cdb0e949525 Mon Sep 17 00:00:00 2001 |From: Richard Mudgett <rmudgett@digium.com> |Date: Mon, 6 Aug 2018 11:24:25 -0500 |Subject: [PATCH 1/5] 0000-configure-ssl-library-path.patch | |--- | aconfigure | 6 +++++- | aconfigure.ac | 6 +++++- | 2 files changed, 10 insertions(+), 2 deletions(-) | |diff --git a/aconfigure b/aconfigure |index 1c449b8..c4c6060 100755 |--- a/aconfigure |+++ b/aconfigure -------------------------- File to patch:
最新发布
07-30
root@ubuntu:/zlab_16t2/changqingteng# echo "/usr/local/lib" | tee /etc/ld.so.conf.d/freesasa.conf /usr/local/lib root@ubuntu:/zlab_16t2/changqingteng# ldconfig -v | grep freesasa /sbin/ldconfig.real: Can't stat /usr/local/lib/i386-linux-gnu: No such file or directory /sbin/ldconfig.real: Path `/usr/lib/i386-linux-gnu' given more than once (from /etc/ld.so.conf.d/i386-linux-gnu.conf:4 and /etc/ld.so.conf.d/i386-linux-gnu.conf:3) /sbin/ldconfig.real: Can't stat /usr/local/lib/i686-linux-gnu: No such file or directory /sbin/ldconfig.real: Can't stat /lib/i686-linux-gnu: No such file or directory /sbin/ldconfig.real: Can't stat /usr/lib/i686-linux-gnu: No such file or directory /sbin/ldconfig.real: Path `/usr/local/lib' given more than once (from /etc/ld.so.conf.d/libc.conf:2 and /etc/ld.so.conf.d/freesasa.conf:1) /sbin/ldconfig.real: Can't stat /usr/local/lib/x86_64-linux-gnu: No such file or directory /sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu' given more than once (from /etc/ld.so.conf.d/x86_64-linux-gnu.conf:4 and /etc/ld.so.conf.d/x86_64-linux-gnu.conf:3) /sbin/ldconfig.real: Path `/usr/lib32' given more than once (from /etc/ld.so.conf.d/zz_i386-biarch-compat.conf:3 and /etc/ld.so.conf.d/zz_i386-biarch-compat.conf:2) /sbin/ldconfig.real: Path `/lib/x86_64-linux-gnu' given more than once (from <builtin>:0 and /etc/ld.so.conf.d/x86_64-linux-gnu.conf:3) /sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu' given more than once (from <builtin>:0 and /etc/ld.so.conf.d/x86_64-linux-gnu.conf:3) /sbin/ldconfig.real: Path `/usr/lib' given more than once (from <builtin>:0 and <builtin>:0) /sbin/ldconfig.real: /lib/i386-linux-gnu/ld-linux.so.2 is the dynamic linker, ignoring /usr/local/lib: (from /etc/ld.so.conf.d/freesasa.conf:1) /sbin/ldconfig.real: /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 is the dynamic linker, ignoring /sbin/ldconfig.real: /lib32/ld-linux.so.2 is the dynamic linker, ignoring 请分析错误原因,并给出详细解决步骤
07-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值