Lib依赖库
来源:互联网 发布:破解java游戏网站 编辑:程序博客网 时间:2024/04/29 04:49
1. 查看依赖库
# ldd xxx
当出现如下错误:error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解决办法:
- 如果是ubuntu,ld默认的目录是/lib和/usr/lib,不会查找/usr/lib64,需要手动添加。redhat会自动查找
- 先用查找命令在相应的lib目录下查找,是否此库文件存在
- 修改 /etc/ld.so.conf 文件,将路径添加到最后即可
- 或者在 /etc/ld.so.conf.d/ 下新建一文件,如 XXX.conf,其内容还是库路径
- # sudo ldconfig
注:每次添加新的库文件时,都需要重新生效
2. 如果找不到
可能是库的权限问题,普通用户用不了
3. 如果还找不到
说明64位系统和32的支持
# sudo apt-get install ia32-libs
4. rpath
man ld,查找链接选项rpath的含义:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-rpath=dir
Add a directory to the runtime library search path. This is used when
linking an ELF executable with shared objects. All -rpath arguments
are concatenated and passed to the runtime linker, which uses them to
locate shared objects at runtime. The -rpath option is also used when
locating shared objects which are needed by shared objects explicitly
included in the link; see the description of the -rpath-link option.
If -rpath is not used when linking an ELF executable, the contents of
the environment variable “LD_RUN_PATH” will be used if it is defined.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
简单翻译下, rpath链接选项主要有两个功能:
- 程序运行时,优先到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.
- linux的默认搜索路径是/lib和/usr/lib,然后按照/etc/ld.so.conf里面的配置搜索绝对路径
- LD_LIBRARY_PATH路径优先于系统默认路径之前查找
- gcc的-R或-rpath选项来在编译时就指定库的查找路径,并且该库的路径信息保存在可执行文件中,运行时它会直接到该路径查找库
6. 动态库的链接
- -L: “链接”的时候,去找的目录。都会先从 -L 指定的目录去找,然后是默认的地方。-L只是指定了程序编译连接时库的路径,并不影响程序执行时库的路径,系统还是会到默认路径下查找该程序所需要的库
- -rpath-link:“链接”的时候,去找的目录
- -rpath(-R): “运行”的时候,去找的目录。对于交叉编译,交叉编译链接器需已经配置 –with-sysroot 选项才能起作用
7. ld链接选项
在gcc中使用ld链接选项时,需要在选项前面加上前缀-Wl(是字母l,不是1),以区别不是编译器的选项
# gcc -Wl,--start-group foo.o bar.o -Wl,--end-group# gcc obs.c -leSDKOBSS3 -Wl,-R,/root/hbu8.0/bin/lib
- Lib依赖库
- IOS lib库依赖设置
- xcode lib库的依赖关系总结
- C++ 为项目的Debug配置增加依赖的库:cxcore200d.lib cv200d.lib highgui200d.lib
- 【Android】lib依赖
- 在QTCreate如何添加LIB依赖库进行编译
- 在QTCreate如何添加LIB依赖库进行编译
- VS2010 解决方案依赖项设置:会导致lib库目录不起作用
- 【iOS开发】创建static lib库做项目依赖及遇到问题
- 批量获取bin/lib链接库依赖关系的shell脚本
- VS中添加LIb库及头文件(外部依赖项)的步骤
- Android Studio把Eclipse android项目当作依赖库lib来使用的一些问题解决
- vs中c++添加lib库和头文件(外部依赖项)
- 使用dumpbin检查.lib的依赖关系
- 通过项目依赖设置LIB引用关系
- VC2010 LIB依赖引用设置方法
- Json-lib依赖的Jar包
- maven 拷贝依赖jar到 lib中
- 第二周项目 2 三角形类2
- 各浏览器对页面外部资源加载的策略
- sql降序,升序
- git常用操作
- entity framework学习
- Lib依赖库
- leetcode || 39、Combination Sum
- Struts2拦截器的使用 (详解)
- Guava cache实现本地缓存
- 实验报告
- 一个程序员应该怎样去学习和掌握计算机英语呢
- Android 开源框架Universal-Image-Loader完全解析(三)---源码解析
- java中的值传递
- 大数据实时处理–Spark及BDAS技术应用