linux下的静态库创建与查看,及如何查看某个可执行依赖于哪些动态库

linux下的静态库创建与查看,及如何查看某个可执行依赖于哪些动态库

 
创建静态库:
ar -rcs test.a *.o
查看静态库:
ar -tv test.a
解压静态库:
ar -x test.a

查看程序依赖的动态库:
readelf -a xxx|grep library
如:可以看到,下面的交叉程序hello执行依赖于如下两个动态库。
rebi@ubuntu:~/test$ arm-none-linux-gnueabi-readelf -a hello|grep "library"
0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x00000001 (NEEDED) Shared library: [libc.so.6]
rebi@ubuntu:~/test$

或者:readelf -l hello 即可。

nm xxx 查看符号
其中,T表示代码段,U表示在其它地方定义,所以需要确保必须在某个.o或库里被定义过。
   ldd命令就可以查看 
原文地址:https://www.cnblogs.com/qingchen1984/p/7260801.html