how linux find dynamic lib?

来源:互联网 发布:centos smtp server 编辑:程序博客网 时间:2024/05/16 12:27

1.LD_LIBRARY_PATH环境变量
2.system default path:
linux:
file: /etc/ld.so.conf
trusted directories: /lib  /usr/lib
通过命令ldconfig来设置:
http://linux.die.net/man/8/ldconfig
solaris:
file: /var/ld/ld.config
crle command:
http://docs.sun.com/app/docs/doc/819-2239/crle-1?a=view
3.write rpath to binary(在编译的时候通过rpath来将寻找链接库的路径写道binary):
LD_RUN_PATH环境变量
-R gcc的参数

 

如果找到include文件的:

gcc首先查找-I选项指定的目录,然后查找系统的头文件目录(通常是/usr/include);

而对于用引号包含的头文件,gcc首先查找包含头文件的.c文件所在的目录,然后查找-I选项指定的目录,然后查找系统的头文件目录。

参见:

http://www.eyrie.org/~eagle/notes/rpath.html
http://learn.akae.cn/media/ch20s04.html
http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html
http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html

原创粉丝点击