Lib依赖库
1. 查看依赖库# ldd xxx
当出现如下错误:error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
注:每次添加新的库文件时,都需要重新生效 2. 如果找不到可能是库的权限问题,普通用户用不了 3. 如果还找不到说明64位系统和32的支持 # sudo apt-get install ia32-libs
4. rpathman ld,查找链接选项rpath的含义: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5. 动态链接的优先级The linker uses the following search paths to locate required shared libraries:
1. Any directories specified by -rpath-link options.
2. Any directories specified by -rpath options. The difference
between -rpath and -rpath-link is that directories specified by
-rpath options are included in the executable and used at runtime,whereas the -rpath-link option is only effective at link time.
Searching -rpath in this way is only supported by native linkers
and cross linkers which have been configured with the
--with-sysroot option.
3. On an ELF system,for native linkers,if the -rpath and -rpath-link
options were not used,search the contents of the environment
variable "LD_RUN_PATH".
4. On SunOS,if the -rpath option was not used,search any directories
specified using -L options.
5. For a native linker,the search the contents of the environment
variable "LD_LIBRARY_PATH".
6. For a native ELF linker,the directories in "DT_RUNPATH" or
"DT_RPATH" of a shared library are searched for shared libraries
needed by it. The "DT_RPATH" entries are ignored if "DT_RUNPATH"
entries exist.
7. The default directories,normally /lib and /usr/lib.
8. For a native linker on an ELF system,if the file /etc/ld.so.conf
exists,the list of directories found in that file.
If the required shared library is not found,the linker will issue a
warning and continue with the link.
6. 动态库的链接
7. ld链接选项在gcc中使用ld链接选项时,需要在选项前面加上前缀-Wl(是字母l,不是1),以区别不是编译器的选项 # gcc -Wl,--start-group foo.o bar.o -Wl,--end-group
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |