| Libraries often rely on code in other libraries. Traditionally the way to deal with this is to know what the dependencies are and, when linking an executable, be careful to list all of the dependencies on the link line in the correct order. If you have ever built an X Window application using a widget library, you will already be familiar with this notion. Even though you only use the functions in the widget library directly, a typical link command would need to be:
With modern architectures, this problem has been solved by allowing libraries to be linked into other libraries, but this feature is not yet particularly portable. If you are trying to write a portable project, it is not safe to rely on native support for inter-library dependencies, especially if you want to have dependencies between static and shared archives. Some of the features discussed in this section were not fully implemented before Libtool 1.4, so you should make sure that you are using this version or newer if you need these features. If you want to try the examples in this section to see what Suppose I want to make two libraries, `libtrim' and `libhello' . `libhello' uses the `trim' function in `libtrim' but the code in `main' uses only the `hello' function in `libhello' . Traditionally, the two libraries are built like this:
Notice that there is no way to specify that `libhello.a' won't work unless it is also linked with `libtrim.a' . Because of this I need to list both libraries when I link the application. What's more, I need to list them in the correct order:
|