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" 0x0000000依 (NEEDED) Shared library: [libgcc_s.so.依] 0x0000000依 (NEEDED) Shared library: [libc.so.陆] rebi@ubuntu:~/test$ 或者:readelf -l hello 即 nm xxx 查看符号 其T表示代码段U表示其定义所需要确保必须某.o或库定
② linux查询静态库是arm平台还是x86平台
X86
File: libcrypto.a(e_padlock.o)
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: REL (Relocatable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 248 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 64 (bytes)
Number of section headers: 11
Section header string table index: 8
e_padlock.o: file format elf64-x86-64
ARM
File: libcrypto.a(gost_sign.o)
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: REL (Relocatable file)
Machine: ARM
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 3508 (bytes into file)
Flags: 0x5000000, Version5 EABI
Size of this header: 52 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 40 (bytes)
Number of section headers: 12
Section header string table index: 9
gost_sign.o: file format elf32-little
③ 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-li...
④ linux如何查看静态库是不是arm提醒
查看系统内核版本,使用 uname 命令。 以致远电子的M3352核心板为例,输入以下命令即可: [root@M3352 ~]# uname -a Linux M3352 3.2.0 #134 Thu Aug 8 15:47:17 CST 2013 armv7l GNU/Linux
⑤ Linux下的静态库和动态库
linux下的静态库和动态库1.制作自己的动态库和静态库linux下动态库以.so结尾,静态库以.a结尾,它们都以lib开头,比如一个库名为net,那么它的全名应该是libnet.so或者libnet.a。我们有两个文件,hello.c和test.c,下面是两个文件的内容//hello.c
www.shiwu.com
#include
<stdio.h>void
my_lib_func(){printf(Library
routine
called/r/n);}//test.c#include
<stdio.h>
www.shiwu.com
int
main(){my_lib_func();return
1;}test.c调用了hello.c的方法,我们把hello.c封装成库文件。无论是静态库还是动态库,都是由.o文件组成,我们先把gcc
-c
hello.c生成.o文件制作静态库ar
crv
libmyhello.a
hello.o,ar是生成静态库的命令,libmyhello.a是我的静态库名。下一步就是在我的程序中使用静态库
可以看到已经有了Library
routine
called的结果,说明调用成功了。下面我们删除libmyhello.a,看看程序是否还是运行正常
我们发现程序依然运行正常,说明静态库已经连接进入我们的程序中制作动态库
www.shiwu.com
我们看见动态库libmyhello.so已经生成,下面继续使用
找不到库文件,这个时候我们把so文件拷贝到/usr/lib下面
运行成功2.动态库和静态库同时存在的调用规则我们可以发现,不论是动态库还是静态库,程序编译连接的时候都是加的参数-l,那么当他们同时存在的时候,程序会选择动态库还是静态库呢。我们做个尝试。
我们同时存在libmyhello.a和libmyhello.so,我们发现运行的时候,出现找不到动态库的错误,由此,我们可以得出结论,同时存在动态库和静态库的时候,gcc会优先选择动态库作者
梨树阳光
⑥ 如何查看静态库内容 Unix/Linux
以下从最好情况->最坏情况:
1. 最好知道静态库的原文件(.c),要是知道声明文件(.h)也比较好。
2. ar -t YourFile 看其结构,找其中的原文件。
3. 可以将库文件下到本地用UE打开,然后你就找吧。
另外,看动态库用 nm -D lib*.so
⑦ 在linux环境下静态库(.a)的编译和使用
假设我们自己编译一个加法程序,和打乱信印程序。
那么我们可以通过下面两个命令将这两个函数编译成扒族静态库。
那么我们可以通过下面的命令(任选一种)将main.cpp与静态库进行哗此轮编译。
待后续补充
⑧ 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或库里被定义过。