Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2097190
  • 博文数量: 414
  • 博客积分: 10312
  • 博客等级: 上将
  • 技术积分: 4921
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-31 01:49
文章分类

全部博文(414)

文章存档

2011年(1)

2010年(29)

2009年(82)

2008年(301)

2007年(1)

分类:

2009-10-11 02:33:54

By definition, every shared library system provides a way for executables to depend on libraries, so that symbol resolution is deferred until runtime.

An inter-library dependency is one in which a library depends on other libraries. For example, if the libtool library libhello uses the cos function, then it has an inter-library dependency on libm, the math library that implements cos.

Some shared library systems provide this feature in an internally-consistent way: these systems allow chains of dependencies of potentially infinite length.

However, most shared library systems are restricted in that they only allow a single level of dependencies. In these systems, programs may depend on shared libraries, but shared libraries may not depend on other shared libraries.

In any event, libtool provides a simple mechanism for you to declare inter-library dependencies: for every library libname that your own library depends on, simply add a corresponding -lname option to the link line when you create your library. To make an example of our libhello that depends on libm:

burger$ libtool --mode=link gcc -g -O -o libhello.la foo.lo hello.lo \

-rpath /usr/local/lib -lm

burger$

When you link a program against libhello, you don't need to specify the same ‘-l’ options again: libtool will do that for you, in order to guarantee that all the required libraries are found. This restriction is only necessary to preserve 【保存,保藏,防腐;保管(贵重品等);保留】 compatibility with static library systems and simple dynamic library systems.

Some platforms, such as AIX, do not even allow you this flexibility. In order to build a shared library, it must be entirely self-contained (that is, have references only to symbols that are found in the ‘.lo’ files or the specified ‘-l’ libraries), and you need to specify the -no-undefined flag. By default, libtool builds only static libraries on these kinds of platforms.

The simple-minded inter-library dependency tracking code of libtool releases prior to 1.2 was disabled because it was not clear when it was possible to link one library with another, and complex failures would occur. A more complex implementation of this concept was re-introduced before release 1.3, but it has not been ported to all platforms that libtool supports. The default, conservative behavior is to avoid linking one library with another, introducing their inter-dependencies only when a program is linked with them.

阅读(983) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~